Oct 29

Pre-Requisites

This article assumes that

  1. The work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.
  2. The user “demo” has sudo access without a password. If this is not the case use the command “su -” and provide the password instead of saying “sudo -i” in the set of commands below

The instructions should work in other RedHat 6-like OS’ and OS versions.

Download alacarte

The alacarte application is a UI for managing the gnome 2 menus. CentOS 6.8, as installed following instructions in the second article in this series, does not include alacarte, so it is necessary to install it. We will do it in two steps – first we will download it and then we will install it form a shared directory. This way we will download it the first time but will subsequently be able to install it on as many images as we care to create without the need to go to the Internet each time.

mkdir -p /media/sf_distros/rpms

sudo yum install -y --downloadonly --downloaddir=/media/sf_distros/rpms alacarte
ls /media/sf_distros/rpms/alacarte*
/media/sf_distros/rpms/alacarte-0.12.4-1.el6.noarch.rpm

Download gconf-editor

The gconf-editor application is a UI for exploring and modifying gnome configuration. CentOS 6.8, as installed following instructions in the second article in this series, does not include gconf-editor, so it is necessary to install it. We will do it in two steps – first we will download it and then we will install it form a shared directory. This way we will download it the first time but will subsequently be able to install it on as many images as we care to create without the need to go to the Internet each time.

mkdir -p /media/sf_distros/rpms
sudo yum install -y --downloadonly --downloaddir=/media/sf_distros/rpms gconf-editor
ls /media/sf_distros/rpms/gconf-editor*
/media/sf_distros/rpms/gconf-editor-2.28.0-3.el6.x86_64.rpm

Create localinstall rpm script

Let’s create a script to install a rpm from the shared directory.

cat <<-'EODECK' > /media/sf_distros/scripts/006_install_local_rpm.sh
#!/bin/bash
rpmNamePattern=${1?"Usage: $0 rpmName # please provide rpm name"}
rpmName=$(ls -c1 /media/sf_distros/rpms/${rpmNamePattern}* ) 2>/dev/null
if [ $? -ne 0 ]; then
    echo "ERROR: No files satisfying the pattern /media/sf_distros/rpms/${rpmNamePattern}*  - can't install ${rpmNamePattern}";
else
    if [ "$(yum list ${rpmNamePattern} 2>/dev/null | grep @/${rpmNamePattern})" == "" ]; then
        echo "Will install ${rpmName}";
        sudo yum -y localinstall ${rpmName}
    else
        echo "${rpmName} is already installed - skipping installation"
    fi
fi

EODECK
chmod ug+x /media/sf_distros/scripts/006_install_local_rpm.sh

Some references:

http://tldp.org/LDP/abs/html/parameter-substitution.html#USAGEMESSAGE

http://www.cyberciti.biz/tips/bash-shell-parameter-substitution-2.html

 

Install alacarte and gconf-editor

Install alacarte

/bin/bash -v /media/sf_distros/scripts/006_install_local_rpm.sh alacarte

Install gconf-editor

/bin/bash -v /media/sf_distros/scripts/006_install_local_rpm.sh gconf-editor

Add Launchers to Top Panel

The launchers are gnome-specific text files which define the various aspects of each launcher, and which can either be added to a panel, as is done in this article, or can be placed on the Desktop, which is done in one or more of the subsequent articles.

See “Integrating existing software with GNOME, Guide for Independent Software Vendors”, https://developer.gnome.org/integration-guide/stable/index.html.en, for specifics of the structure of the *.desktop file.

If you worked through the previous article, your top panel will look like in the following illustration.

038_centos_top_panel_after

The launchers for the top panel will go into a specific directory under the user’s home directory, in my case it will be “~/.gnome2/panel2.d/default/launchers/”.

Let’s create a script which adds Alacarte, Gedit, pre-configured gnome-terminal, Nautilus File Manager and KDE Monitor to the top panel.

Note, in the script below, that while we are creating the *.desktop files each time, we are verifying whether the particular launcher has already been added to the panel and are not adding it if it has. This is because each time the gnome-panel-add command is execute a new launcher is added regardless of whether an identical one is already there.

mkdir -p /media/sf_distros/scripts
cat <<-EODECK > /media/sf_distros/scripts/007_add_standard_launchers_to_top_panel.sh
#!/bin/bash
mkdir -p ${HOME}/.gnome2/panel2.d/default/launchers/
cat <<-EOF > ${HOME}/.gnome2/panel2.d/default/launchers/alacarte.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=alacarte
Name=alacarte
Icon=alacarte
EOF
/usr/bin/gconftool-2 --dump /apps/panel/objects | grep alacarte.desktop 2>/dev/null 1>&2
if [ \$? -eq 0 ]; then
    echo "Launcher for alacarte already in the top panel";
else
    /usr/libexec/gnome-panel-add --panel=top_panel --launcher=${HOME}/.gnome2/panel2.d/default/launchers/alacarte.desktop --position=710
fi

cat <<-EOF > ${HOME}/.gnome2/panel2.d/default/launchers/gedit.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=gedit
Name=gedit
Icon=/usr/share/icons/gnome/scalable/apps/accessories-text-editor.svg
EOF
/usr/bin/gconftool-2 --dump /apps/panel/objects | grep gedit.desktop 2>/dev/null 1>&2
if [ \$? -eq 0 ]; then
    echo "Launcher for gedit already in the top panel";
else
    /usr/libexec/gnome-panel-add --panel=top_panel --launcher=${HOME}/.gnome2/panel2.d/default/launchers/gedit.desktop --position=280
fi

cat <<-EOF > ${HOME}/.gnome2/panel2.d/default/launchers/gnome-terminal.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=gnome-terminal --geometry 100x24+800+350
Name=gnome-terminal
Icon=/usr/share/icons/gnome/scalable/apps/utilities-terminal.svg
EOF
/usr/bin/gconftool-2 --dump /apps/panel/objects | grep gnome-terminal.desktop 2>/dev/null 1>&2
if [ \$? -eq 0 ]; then
    echo "Launcher for gnome-terminal already in the top panel";
else
    /usr/libexec/gnome-panel-add --panel=top_panel --launcher=${HOME}/.gnome2/panel2.d/default/launchers/gnome-terminal.desktop --position=290
fi

cat <<-EOF > ${HOME}/.gnome2/panel2.d/default/launchers/file-browser.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=nautilus --no-desktop --browser %U
Name=File Browser
Icon=/usr/share/icons/gnome/scalable/apps/system-file-manager.svg
EOF
/usr/bin/gconftool-2 --dump /apps/panel/objects | grep file-browser.desktop 2>/dev/null 1>&2
if [ \$? -eq 0 ]; then
    echo "Launcher for nautilus already in the top panel";
else
    /usr/libexec/gnome-panel-add --panel=top_panel --launcher=${HOME}/.gnome2/panel2.d/default/launchers/file-browser.desktop --position=310
fi

cat <<-EOF > ${HOME}/.gnome2/panel2.d/default/launchers/ksystem-monitor.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=ksysguard %U
Name=System Monitor
Icon=/usr/share/icons/gnome/scalable/apps/kde-utilities-system-monitor.svg
EOF
/usr/bin/gconftool-2 --dump /apps/panel/objects | grep ksystem-monitor.desktop 2>/dev/null 1>&2
if [ \$? -eq 0 ]; then
    echo "Launcher for KDE Monitor already in the top panel";
else
    /usr/libexec/gnome-panel-add --panel=top_panel --launcher=${HOME}/.gnome2/panel2.d/default/launchers/ksystem-monitor.desktop --position=860
fi

EODECK
chmod ug+x /media/sf_distros/scripts/007_add_standard_launchers_to_top_panel.sh

Execute the script to add top panel launchers, and test them.

/bin/bash /media/sf_distros/scripts/007_add_standard_launchers_to_top_panel.sh

The top panel will now have extra tools

039_centos_top_panel_after_launchers

Configure the nautilus file browser to show a list view, specific columns and files as well as directories and hidden files.

Examine the default display

nautilus --browser &

Create the configuration script

mkdir -p /media/sf_distros/scripts
cat <<-EODECK > /media/sf_distros/scripts/008_configure_nautilus_file_browser.sh
gconftool-2 -s -t list --list-type string /apps/nautilus/list_view/default_visible_columns "[name,size,type,date_modified,date_accessed,owner,group,where,permissions,octal_permissions]"
gconftool-2 -s -t list --list-type string /apps/nautilus/preferences/default_folder_viewer "[name,size,type,date_modified,owner,group,where,permissions,octal_permissions]"
gconftool-2 -s -t string /apps/nautilus/preferences/default_folder_viewer "list_view"
gconftool-2 -s -t bool /apps/nautilus/sidebar_panels/tree/show_only_directories "false"
gconftool-2 -s -t bool /apps/nautilus/icon_view/default_use_tighter_layout "true"
gconftool-2 -s -t bool /apps/nautilus/compact_view/all_columns_have_same_width "false"
gconftool-2 --type boolean --set /desktop/gnome/file_views/show_hidden_files "true"
EODECK
chmod ug+x /media/sf_distros/scripts/008_configure_nautilus_file_browser.sh

Execute the script

/bin/bash -v /media/sf_distros/scripts/008_configure_nautilus_file_browser.sh

Examine the changes

nautilus --browser &

It is expected that the image being configured a bit at a time in this series of articles will be created more than once for different purposes. With this assumptions the individual scripts are appended to a single script so that the second and subsequent images can be configured by a single script rather than having lots of scripts to execute manually.

Append “add launchers to top panel and configure nautilus” script execution commands to the initial bulk configuration script. This script is intended to collect all automated configuration commands and scripts so that they can be all executed in one go on a brand new image if one gets to do this the second and subsequent times.

Don’t actually execute this script while you are building the first image.

cat <<-'EODECK' >> /media/sf_distros/scripts/000_initial_bulk_configuration.sh
# install alacarte and gnome-editor
/bin/bash -v /media/sf_distros/scripts/006_install_local_rpm.sh alacarte

# add launchers to top panel
/bin/bash /media/sf_distros/scripts/007_add_standard_launchers_to_top_panel.sh

# configure nautilus file browser
/bin/bash -v /media/sf_distros/scripts/008_configure_nautilus_file_browser.sh

EODECK
chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh
Oct 21

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article a script which will add GEyes, ShowDesktop and GnomeMonitor applests and configure the GnomeMonitor applet will be developed and executed.

Pre-Requisites

This article assumes that

  1. The work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.

The instructions should work in other RedHat 6-like OS’ and OS versions.

Script Adding Applets to Top Panel

I typically set up my environment to my taste, which does not mean that everybody needs to do this the same way or at all.

The discussion below shows how one can script adding and configuration of top panel applets.

Remember that all this can be done using the relevant UIs but my objective is to create configuration scripts which I can execute and have the demo image configured without having to tediously manipulate various UIs.

Let’s have a look at some applets-related commands and outputs, and then create and execute a script to add three applets to the top panel using a script.

After CentOS installation the top panel looks like that shown in the figure below.

037_centos_top_panel_before

Let’s list top level panels so as to see which ones we have – top and bottom is what is expected.

/usr/bin/gconftool-2 --all-dirs /apps/panel/toplevels

/apps/panel/toplevels/top_panel
/apps/panel/toplevels/bottom_panel

List applets in the two panels

/usr/bin/gconftool-2 --all-dirs /apps/panel/applets

/apps/panel/applets/trash_applet
/apps/panel/applets/workspace_switcher
/apps/panel/applets/window_list
/apps/panel/applets/fast_user_switch_applet
/apps/panel/applets/systray
/apps/panel/applets/gnote
/apps/panel/applets/clock

List all available applets which can be added to the panels

/usr/bin/activation-client -q --spec="has (repo_ids,'IDL:Bonobo/Control:1.0')" | grep '^IID' | cut -d ',' -f1-1 | cut -d ' ' -f2-2 | more

OAFIID:GNOME_MixerApplet
OAFIID:DwellClickApplet
OAFIID:GNOME_SystemTrayApplet
OAFIID:GNOME_NotificationAreaApplet
OAFIID:GNOME_Panel_TrashApplet
OAFIID:GNOME_ClockApplet
OAFIID:GNOME_AccessxStatusApplet
OAFIID:Invest_Applet
OAFIID:GnoteApplet
OAFIID:GNOME_MailcheckApplet
OAFIID:GNOME_CDPlayerApplet
OAFIID:GNOME_FishApplet
OAFIID:GNOME_GeyesApplet
OAFIID:GNOME_GtikApplet
OAFIID:GNOME_WindowMenuApplet
OAFIID:GNOME_KeyboardApplet
OAFIID:GNOME_GWeatherApplet
OAFIID:GNOME_BattstatApplet
OAFIID:GNOME_PagerApplet
OAFIID:GNOME_WorkspaceSwitcherApplet
OAFIID:GNOME_TasklistApplet
OAFIID:GNOME_MultiLoadApplet
OAFIID:GNOME_StickyNotesApplet
OAFIID:GNOME_ShowDesktopApplet
OAFIID:GNOME_WindowListApplet
OAFIID:GNOME_DriveMountApplet
OAFIID:GNOME_CharpickerApplet
OAFIID:GNOME_DictionaryApplet
OAFIID:GNOME_FastUserSwitchApplet
OAFIID:GNOME_GDictApplet
OAFIID:PointerCaptureApplet
OAFIID:GNOME_BrightnessApplet
OAFIID:Square_Controller
OAFIID:Circle_Controller
OAFIID:Bonobo_Sample_Entry
OAFIID:GNOME_CPUFreqApplet
OAFIID:GNOME_MiniCommanderApplet

Create the script to update property values in the applet dump file. This script will be used later to update specific key values. If you are curious, execute the script lines one at a time to see what they do.

mkdir -p /media/sf_distros/scripts
cat <<-'EODECK' > /media/sf_distros/scripts/z_update_upplet_config_key.sh
#!/bin/bash
# update value for key in applet dump for a particular applet
# expect applet dump file, key and value pair as $1, $2 and $3
fileName=${1}
keyName=${2}
valueName=${3}
echo -- before : processing ${fileName}, key: ${keyName}, for value ${valueName}
cat ${fileName} | grep -A 2 "${keyName}<"
matchedLine=$(cat ${fileName} | grep -n "${keyName}<")
matchedLineNum=$(echo ${matchedLine} | cut -d ':' -f 1)
replaceLineNum=$(echo $(( ${matchedLineNum} + 3)))
sed -i "${replaceLineNum}s|<\([a-z]*\)>.*</\([a-z]*\)>|<\1>${valueName}</\1>|" ${fileName}
echo ++ after
cat ${fileName} | grep -A 2 "${keyName}<"
EODECK
chmod ug+x /media/sf_distros/scripts/z_update_upplet_config_key.sh

Create a script which will add three applets to the top bar and configure the monitor applet

mkdir -p /media/sf_distros/scripts
cat <<-'EODECK' > /media/sf_distros/scripts/005_add_applets_to_top_panel.sh
# Add GEyes to the top bar
/usr/libexec/gnome-panel-add --applet=OAFIID:GNOME_GeyesApplet --panel=top_panel --position=849 --copy-launcher

# Add Show Desktop Applet to the top bar
/usr/libexec/gnome-panel-add --applet=OAFIID:GNOME_ShowDesktopApplet --panel=top_panel --position=400 --copy-launcher

# Add Monitor Applet to the top bar
/usr/libexec/gnome-panel-add --applet=OAFIID:GNOME_MultiLoadApplet --panel=top_panel --position=980 --copy-launcher

# Dump applet_2 configuration - that will be the last applet added above - MultiLoadApplet
sleep 2
gconftool-2 --dump /apps/panel/applets/applet_2 > ~/applet_2_fix.entries
sleep 2

# Update property values and load the updated entries
/media/sf_distros/scripts/z_update_upplet_config_key.sh ~/applet_2_fix.entries view_netload true
/media/sf_distros/scripts/z_update_upplet_config_key.sh ~/applet_2_fix.entries view_diskload true
/media/sf_distros/scripts/z_update_upplet_config_key.sh ~/applet_2_fix.entries view_loadavg true
/media/sf_distros/scripts/z_update_upplet_config_key.sh ~/applet_2_fix.entries view_swapload true
/media/sf_distros/scripts/z_update_upplet_config_key.sh ~/applet_2_fix.entries view_memload true
/media/sf_distros/scripts/z_update_upplet_config_key.sh ~/applet_2_fix.entries size 30

gconftool-2 --load ~/applet_2_fix.entries
killall gnome-panel

EODECK
chmod ug+x /media/sf_distros/scripts/005_add_applets_to_top_panel.sh

Execute the commands

/bin/bash -v /media/sf_distros/scripts/005_add_applets_to_top_panel.sh

After script execution the top panel looks like the following

038_centos_top_panel_after

List the applets now in the panels

/usr/bin/gconftool-2 --all-dirs /apps/panel/applets
 /apps/panel/applets/clock
 /apps/panel/applets/applet_0
 /apps/panel/applets/applet_1
 /apps/panel/applets/applet_2
 /apps/panel/applets/trash_applet
 /apps/panel/applets/window_list
 /apps/panel/applets/systray
 /apps/panel/applets/workspace_switcher
 /apps/panel/applets/gnote
 /apps/panel/applets/fast_user_switch_applet

It is expected that the image being configured a bit at a time will be created multiple times. With this assumptions the individual scripts are appended to a single script so that the second and subsequent images can be configured by a single script rather than having lots of scripts to execute manually.

Append “add applets to top panel and configure monitor” script execution commands to the initial bulk configuration script. This script is intended to collect all automated configuration commands and scripts so that they can be all executed in one go on a brand new image if one gets to do this the second and subsequent times.

Don’t actually execute this script while you are building the first image.

cat <<-'EODECK' >> /media/sf_distros/scripts/000_initial_bulk_configuration.sh
# add and configure top panel applets
/bin/bash -v /media/sf_distros/scripts/005_add_applets_to_top_panel.sh

EODECK
chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh
Oct 21

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article I am creating and executing a script which will disable unneeded services.

Pre-Requisites

This article assumes that

  1. The work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.
  2. The user “demo” has sudo access without a password. If this is not the case use the command “su -” and provide the password instead of saying “sudo -i” in the set of commands below

The instructions should work in other RedHat 6-like OS’ and OS versions.

Disable unneeded Services

Create and execute a script which will disable some unneeded services.

Remember that all this can be done manually but my objective is to create configuration scripts which I can execute and have the demo image configured without having to tediously manipulate various UIs.

mkdir -p /media/sf_distros/scripts
cat <<-'EODECK' > /media/sf_distros/scripts/004_disable_unneeded_services.sh
# disable unneeded services
sudo chkconfig postfix off
sudo chkconfig pcscd off
sudo chkconfig openct off
sudo chkconfig bluetooth  off

sudo service postfix stop
sudo service pcscd stop
sudo service openct stop
sudo service bluetooth  stop

EODECK
chmod ug+x /media/sf_distros/scripts/004_disable_unneeded_services.sh

Execute the commands

/bin/bash -v /media/sf_distros/scripts/004_disable_unneeded_services.sh

Append “disable unneeded services” script execution commands to the initial bulk configuration script. This script is intended to collect all automated configuration commands and scripts so that they can be all executed in one go on a brand new image if one gets to do this the second and subsequent times.

Don’t actually execute this script while you are building the first image.

cat <<-'EODECK' >> /media/sf_distros/scripts/000_initial_bulk_configuration.sh
# disable unneeded services
/bin/bash -v /media/sf_distros/scripts/004_disable_unneeded_services.sh

EODECK
chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh
Oct 16

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article I am disabling the Linux firewall and SELinux-based security in the CentOS 6.8 – this is a demo image, run only sporadically, for short periods of time and typically with no connection to any network, and is typically restored to a snapshot before each execution.

Pre-Requisites

This article assumes that

  1. The work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.
  2. The user “demo” has sudo access without a password. If this is not the case use the command “su -” and provide the password instead of saying “sudo -i” in the set of commands below

The instructions should work in other RedHat 6-like OS’ and OS versions.

Disable SELinux Security

Since it is a demo environment disable Firewall and SELinux.

Remember that all this can be done manually but my objective is to create configuration scripts which I can execute and have the demo image configured without having to tediously manipulate various UIs.

mkdir -p /media/sf_distros/scripts
cat <<-'EODECK' > /media/sf_distros/scripts/003_disable_firewall_and_selinux.sh

# disable firewall and selinux
sudo chkconfig iptables off
sudo chkconfig ip6tables off
sudo service iptables stop
sudo service ip6tables stop

# change SELINUX=enforcing to SELINUX=disabled
sudo cp /etc/selinux/config /etc/selinux/config_orig
sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

EODECK
chmod ug+x /media/sf_distros/scripts/003_disable_firewall_and_selinux.sh

Execute the commands

/media/sf_distros/scripts/003_disable_firewall_and_selinux.sh

Append “disable firewall and SELinux” script execution commands to the initial bulk configuration script. This script is intended to collect all automated configuration commands and scripts so that they can be all executed in one go on a brand new image if one gets to do this the second and subsequent times.

Don’t actually execute this script while you are building the first image.

cat <<-'EODECK' >> /media/sf_distros/scripts/000_initial_bulk_configuration.sh
# disable firewall and selinux
/media/sf_distros/scripts/003_disable_firewall_and_selinux.sh

EODECK
chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh
Oct 16

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article we are creating a script to disable the screen saver and other delays in the CentOS 6.8 desktop, and appending it to the initial create configuration script which we are incrementally building for the second and subsequent images.

Pre-Requisites

This article assumes that

  1. The work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.

The instructions should work in other RedHat 6-like OS’ and OS versions.

Disable screensaver and other delays

The commands in the script below will disable screensaver and other delays in the Gnome 2 desktop.

Remember that all this can be done using the relevant UIs but my objective is to create configuration scripts which I can execute and have the demo image configured without having to tediously manipulate various UIs.

mkdir -p /media/sf_distros/scripts
cat <<-'EODECK' > /media/sf_distros/scripts/002_disable_screen_saver_and_delays.sh
# disable screen saver and other delays
gconftool-2 -s -t bool /apps/gnome-screensaver/idle_activation_enabled false
gconftool-2 -s -t bool /apps/gnome-screensaver/lock_enabled false
gconftool-2 -s -t int /apps/gnome-screensaver/idle_delay 0
gconftool-2 -s -t int /apps/gnome-screensaver/logout_delay 0
gconftool-2 -s -t int /apps/gnome-screensaver/cycle_delay 0

EODECK
chmod ug+x /media/sf_distros/scripts/002_disable_screen_saver_and_delays.sh

Execute the commands

/media/sf_distros/scripts/002_disable_screen_saver_and_delays.sh

Append “disable screensaver and other delays” script execution commands to the initial bulk configuration script. This script is intended to collect all automated configuration commands and scripts so that they can be all executed in one go on a brand new image if one gets to do this the second and subsequent times.

Don’t actually execute this script while you are building the first image.

cat <<-'EODECK' >> /media/sf_distros/scripts/000_initial_bulk_configuration.sh
# disable screen saver and other delays
/media/sf_distros/scripts/002_disable_screen_saver_and_delays.sh

EODECK
chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh
Oct 13

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article I am configuring CentOS 6.8 Grub boot loader so that it shows detailed feedback at boot rather than the “progress bar” that is shows by default.

Pre-Requisites

This article assumes that

  1. The work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.
  2. The user “demo” has sudo access without a password. If this is not the case use the command “su -” and provide the password instead of saying “sudo -i” in the set of commands below

The instructions should work in other RedHat 6-like OS’ and OS versions.

Show Detailed Boot Feedback

Fix /boot/grub/grub.conf so that the detailed boot feedback is shown at boot instead of a “progress bar”

Remember that all this can be done using the relevant UIs, like a text editor in this case, but my objective is to create configuration scripts which I can execute and have the demo image configured without having to tediously manipulate various UIs.

Append commands to the fix grub script

mkdir -p /media/sf_distros/scripts
cat <<-'EODECK' > /media/sf_distros/scripts/001_fix_grub_boot_loader_configuration.sh

# save a backup of the grub boot loader configuration file and change it so detailed feedback is shown
cp /boot/grub/grub.conf /boot/grub/grub.conf_orig
sed -i 's/rhgb quiet//' /boot/grub/grub.conf

EODECK
chmod ug+x /media/sf_distros/scripts/001_fix_grub_boot_loader_configuration.sh

Execute the commands as root

sudo /media/sf_distros/scripts/001_fix_grub_boot_loader_configuration.sh

Append “fix grub” script execution commands to the initial bulk configuration script. This script is intended to collect all automated configuration commands and scripts so that they can be all executed in one go on a brand new image if one gets to do this the second and subsequent times.

Don’t actually execute this script while you are building the first image.

cat <<-'EODECK' >> /media/sf_distros/scripts/000_initial_bulk_configuration.sh
# set grub boot loader to be verbose
/media/sf_distros/scripts/001_fix_grub_boot_loader_configuration.sh

EODECK
chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh

Reboot to verify the change

sudo reboot

If you don’t do this but still want to occasionally see the details use Alt+E key combination when the progress bar is showing at boot – it works as a toggle

Oct 13

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article I am configuring the OS so that the demo user:

  1. Is automatically logged in at boot and whenever they log out
  2. Can sudo without a password
  3. Can freely access the VirtualBox shared folder

Pre-Requisites

This article assumes that the work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.

The instructions should work in other RedHat 6-like OSes and OS versions.

Enable autologin for demo user

Enable autologin for the demo user so that on boot demo user is automatically logged in

su - # welcome1

cp /etc/gdm/custom.conf /etc/gdm/custom.conf_orig

sed -i 's/\[daemon\]/\[daemon\]\
AutomaticLoginEnable=true\
AutomaticLogin=demo\
/' /etc/gdm/custom.conf


reboot

Reboot to verify that demo user is logged in automatically

Add demo user to sudoers

Add demo to sudo’ers with all rights and no need to enter password

su - # welcome1

rm -f /dev/shm/sudoers
cp -f /etc/sudoers /dev/shm/sudoers

insertAfter=$(( $(grep -n "## Allow root to run any commands anywhere" /dev/shm/sudoers \
| cut -d ":" -f1-1) + 2)); echo ${insertAfter}

ed /dev/shm/sudoers <<-END
${insertAfter}i
demo    ALL=(ALL)       NOPASSWD:ALL
.
w
q
END

grep -B2 -A2 demo /dev/shm/sudoers
cp -f /dev/shm/sudoers /etc/sudoers # needs manual acknowledgement with "yes"

exit

sudo ls -al /root

Allow user to freely use Virtual Box shared folder

Include demo account in vboxsf group so that the user can freely use vbox shared folder. This assumes that the sahred folder was created with the name “distros”. If it was created with a different name change the commands accordingly.

ls -al /media/sf_distros # verify that you don’t have access to the shared folder
sudo usermod -G vboxsf demo

Log out and log back in for this to take effect

ls -al /media/sf_distros # verify that you now have access to the shared folder
Oct 08

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” for rationale, introduction and links to articles in this series.

In this article I am configuring a Virtual Box Machine Image and installing and configuring the CentOS 6.8 OS and the Virtual Box Guest Additions. At the end of the process there will be a Virtual Box Machine Image with CentOS 6.8 installed, snapshot taken and image ready for further work.

All future articles in this series will assume that the image created this way is the baseline for further work.

Host Assumptions

I assume that the demonstration image is built as a Virtual Box 5.x virtual machine image and that the Virtual Box Host environment is Windows 7. This is not a hard requirement but merely an explanation of the Windows’isms which necessarily creep into this document, particularly when it comes to downloading distribution packages prior to image creation.

I assume that you installed the Oracle VirtualBox software on your chosen host, Windows 7 in my case, and are in position to create Virtual Machine Image using the CentOS 6.8 iso as a starting point.

Download assumptions

I assume that the platform from which the image will be created is Windows 7 and that the Windows directory to which packages will be downloaded is

O:\DemoBuilding\Distros

If you are working your way through this series and use either a different host OS or a different download file location then make appropriate adjustments.

Downloading Software Packages

All packages which I am using are, as far as I am aware, free to download. It is your responsibility to ensure that you have the right to download and use the software which I am discussing in this document.

Instructions for downloading, installing and configuring the software packages are provided when the package is first used.

Create and Configure baseline CentOS 6.8 VM Image

Download CentOS 6 Update 8

CentOS, https://wiki.centos.org, is a RedHat-like Linux distribution, available free of charge for any use as far as I can tell.

Download the CentOS 6.8 distribution from the nearest mirror, http://isoredirect.centos.org/centos/6/isos/x86_64/. For me this is http://centos.mirror.digitalpacific.com.au/6.8/isos/x86_64/.

I choose to download the two DVD iso images, CentOS-6.8-x86_64-bin-DVD1.iso and CentOS-6.8-x86_64-bin-DVD2.iso to my distribution packages directory

O:\DemoBuilding\Distros

http://centos.mirror.digitalpacific.com.au/6.8/isos/x86_64/CentOS-6.8-x86_64-bin-DVD1.iso

http://centos.mirror.digitalpacific.com.au/6.8/isos/x86_64/CentOS-6.8-x86_64-bin-DVD2.iso

Create and configure VM Image using the GUI (command line version next section)

Start the VirtualBox Management UI – for me

"C:\Program Files\Oracle\VirtualBox\VirtualBox.exe"

Verify the location to which virtual machine files will be written and change as appropriate.

Choose Machine –> New

000_vboxmgr_machine_new

Name the image “demo”, configure the following settings:

Type: Linux

Version: Other Linux (64-bit) – I am assuming that you have a 64 bit machine if not adjust accordingly

Memory Size: 4096 MB – that should be sufficient for what I have in mind. Increase as needed.

Check “Create a Virtual Hard Disk Now”

001_vbox_create_virtual_hard_disk

Click Create

Define name and location of the new hard disk – I prefer to keep all my VM files in the same place, which will happen if I correctly configure the location to which the files will go to by default.

Complete the dialogue box as follows:

File location: name – this assumes that the default location for the virtual disk file is used

File Size: 120MB

Check “VDI”

Check “Dynamically Allocated”

002_vboxmgr_dynamically_allocated

Click Create

Right-click the name of the new Virtual Box machine and choose Settings

003_vboxmgr_choose_settings

In “General”–>”Advanced” change “Shared Clipboard” and “Drag and Drop” to “bidirectional”

004_vboxmgr_shared_bidirectional

System–>Motherboard–>Boot Order: Uncheck Floppy

005_vboxmgr_uncheck_floppy

System–>Processor–>Processors: set a 1 less than the number of processors on your machine or some other number less than the total number of processors, possibly with the execution cap of less than 100% if you set this to the number of processors.

006_vboxmgr_number_of_cpus

Display–>Screen: set Video Memory to 128MB and enable 3D acceleration

007_vboxmgr_video_memory

Storage –> Storage –> Controller: IDE –> demo.vdi: Check solid state drive if your vdi file is on a solid state drive (highly recommended for performance of your VM)

Storage –> Storage –> Controller: IDE –> Empty –> Optical Drive: select Choose Virtual Optical Drive File…, then navigate to the location of the CentOS 6.8 DVD 1 iso and select it: O:\DemoBuilding\Distros\CentOS-6.8-x86_64-bin-DVD1.iso

009_vboxmgr_iso

010_vboxmgr_iso_2

Network –> Adapter 1: Confirm that you have NAT network selected and if not select it. We want to be able to update the image or get missing packages over the Internet

011_vboxmgr_nat

Shared Folders –> Shared Folders –> Folder List: click Add new Shared Folder (+) icon, navigate to the location to which you downloaded the CentOS iso distribution disks and choose that folder. Check the Auto-mount checkbox and click OK

012_vboxmgr_shared_folder

User Interface –> Check “Show at top of screen”

013_misc

Click OK to finish configuration

Boot the VM with the CentOS DVD 1 iso in the optical drive by selecting the new “demo” image in the Virtual Box Manager tree and clicking “Start”, or following the right-click menu selections over the “demo” image

014_vboxmgr_start

Create and configure VM using command line (instead of the GUI – above)

If you configured the VM using the GUI following the steps in the previous section then you don’t need to execute the command in this section. If you skipped the previous section because you want to configure the VM using the command line, carry on.

I used some of the material in http://superuser.com/questions/741734/virtualbox-how-can-i-add-mount-a-iso-image-file-from-command-line

With the VM not started, in the DOS Box / CMD window, execute the following commands:

set VBM="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"

@create and register bare VM
 %VBM% createvm --name "demo" --ostype "RedHat_64" --register

@rem Execute the following to determine where the files are going and make sure to use that directory path in creating thwe disk
 %VBM% showvminfo "demo" | find "Config file:"

@rem set the disk file location and name
 set diskFile=d:\VirtualBoxDisks\demo\demo.vdi

%VBM% storagectl "demo" --name IDE --add ide --controller PIIX4 --portcount 2 --bootable on
 %VBM% createhd --filename %diskFile% --size 120000
 %VBM% storageattach "demo" --storagectl "IDE" --port 0 --device 0 --type hdd --medium %diskFile%

%VBM% modifyvm "demo" --clipboard bidirectional
 %VBM% modifyvm "demo" --boot1 dvd
 %VBM% modifyvm "demo" --boot2 disk
 %VBM% modifyvm "demo" --boot3 none
 %VBM% modifyvm "demo" --boot4 none
 %VBM% modifyvm "demo" --cpus 3
 %VBM% modifyvm "demo" --cpuexecutioncap 100
 %VBM% modifyvm "demo" --memory 4096
 %VBM% modifyvm "demo" --vram 128
 %VBM% modifyvm "demo" --accelerate3d on
 %VBM% modifyvm "demo" --rtcuseutc on
 %VBM% modifyvm "demo" --paravirtprovider default
 %VBM% modifyvm "demo" --mouse ps2
 %VBM% modifyvm "demo" --usb on
 %VBM% modifyvm "demo" --usbehci on
 %VBM% modifyvm "demo" --nic1 nat
 %VBM% modifyvm "demo" --nicspeed1 10000000
 %VBM% modifyvm "demo" --macaddress1 auto
 %VBM% sharedfolder add "demo" --name "distros" --hostpath "O:\DemoBuilding\Distros" --automount
 %VBM% setextradata "demo" "GUI/MiniToolBarAlignment" "Top"

@rem mount the iso image for installation
 %VBM% storageattach "demo" --storagectl IDE --port 1 --device 0 --type dvddrive --medium "O:\DemoBuilding\Distros\CentOS-6.8-x86_64-bin-DVD1.iso"

Boot the VM with the CentOS DVD 1 iso in the optical drive

%VBM% startvm "demo"

Install CentOS 6.8

When you bot the VM after it is created the installation process will start. You will need to have the 1st iso mounted, which it will be if you followed the steps above. If you choose the options I chose below you will need to mount the 2nd iso to mount as well so make sure you have both before you start.

Make sure that the “Install or upgrade an existing system” is selected and press “Enter”

015_centos_choose_install_option

Skip media testing

021_centos_skip_media_test

022_centos_next_from_splashscreen

  • Next

Choose “English (English)” language (if you choose another language you will need to make such changes in the instructions as will be necessary to compensate for the fact that this guide is written in English for an English language OS)

023_centos_choose_language

  • Next

Choose US English keyboard

024_centos_choose_keyboard

  • Next

Choose Basic Storage Device

025_centos_choose_basic_storage_device

  • Next

Click “Yes, discard any data”

026_centos_yes_discard_any_data

Enter “demo.demodomain.org” into the “Host” box and click the “Configure Network” button

027_centos_configure_network_1

Choose “System eth0” and click Edit

028_centos_choose_eth0_and_edit

Check “Connect Automatically” and click “Apply”

029_centos_connect_automatically

Click Close

  • Next

Choose your timezone – Mine is Sydney/Australia

  • Next

Set root password to welcome1 (or whatever you prefer and will remember)

  • Next

Choose “Create custom layout”

030_centos_custom_layout

  • Next

Select “Hard Drives –> sda –> Free” node in the node tree and click “Create”

031_centos_create_hard_drive_1

Select “Standard partition” and click “Create”

Change “File System Type” to “swap”

Set “Size (MB)” to 8192

Ensure “Fixed Size” is selected then click “OK”

032_centos_add_swap

Select “Hard Drives –> sda –> Free” node in the node tree and click “Create”

033_centos_add_partition

Select “Standard partition” and click “Create”

Enter “/” for “Mount Point”

Retain “File System Type” of “ext4”

Check “Fill to maximum allowable size” and Click “Create”

034_centos_add_root_partition

  • Next

Click “Format”

035_centos_format

Click “Write changes to disk”

Accept “Install boot loader on /dev/sda”

036_centos_accpet_bootloader_location

  • Next

Choose “Software Development Workstation”

Select “Customize Now”

  • Next

Applications –>

Uncheck: “TeX Support” and “Technical Writing”

Select “Graphics Support Tools”, click “Optional Packages”, select “ImageMagick”, “Close”

Base System –>

Uncheck: Directory Client, Java Platform, Network File System Client, Performance Tools, Printing Client

Check: Compatibility Libraries

Databases –>

Check: MySQL Database Client, click “Optional Packages”, select MySQL Python, mysql-connector-java, mysql-connector-odbc, click “Close”

Check MySQL Database Server

Desktops –>

Check KDE Desktop (all checkboxes will be checked)

Select “Fonts”, click “Optional Packages”, uncheck all the fonts that you will not need, amd check “bitmap-lucida” and “bitmap-fixed”

Servers –> Check CIFS File Server

Virtualization –> uncheck all options

  • Next

Installation will now proceed, with 1529 packages to be installed

  • Reboot

Click Forward

Click Forward

Username: demo

Password: welcome1

Click Forward

Check date and time and click Forward

Click Finish

Log in as use demo/welcome1

Install Virtual Box Guest Additions

Pull down the “Devices” menu of the running Virtual Box Image and choose “Insert Guest Additions CD image…”

016_centos_install_vbox_guest_1

Click “OK” when the dialogue box opens

017_centos_install_vbox_guest_2

Click “Run”

Provide root password welcome1 and click “Authenticate”

Observe feedback in the terminal window the installer opens

018_centos_install_vbox_guest_3

Press Return/Enter to close the window.

Right-click on the VBOXADDITIONS… icon on the Desktop and choose “Eject”

019_centos_install_vbox_guest_4

Reboot the image: System -> Shutdown -> Reboot

Shut down the image and snapshot

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" snapshot "demo" take "v1.0.0 Baseline - CentOS 6.8 Installed" --description "v1.0.0 Baseline - CentOS 6.8 Installed"

Configure the VM Image for screen resolution and other things

Assume that the VBoxManage.exe is installed in a default location, that the host is a Windows host and that the name of the VM image is “demo”.

In a command / terminal window of the host machine, while the VM is running, execute the following (or similar command if your host is not Windows) to see what your Virtual Box configuration is.

"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo "demo"

With the VM running execute the following (or similar command if your host is not Windows) to set non-standard video modes and memory pre-allocation.

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode1" "1440x900x32"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1366x768x32"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1920x1080x32"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1720x1000x32"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1600x836x32"

This too needs the VM to be running

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1440 900 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1366 768 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1920 1280 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1720 1000 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1600 836 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" VBoxInternal/RamPreAlloc 1

Shut down the VM

With the VM shut down execute the following (or similar command if your host is not Windows) to set the speed of the NIC

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyvm "demo" --nicspeed1 10000000

Boot the VM

For working in “comfort”

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1600x836x32"

The one below needs VM running

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "demo"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1600 836 32Shut the image down and use the Virtual Box Manager to take a Snapshot of the image. Name the snapshot "v1.0.0 Installed CentOS 6.8 and Virtual Box Guest Additions"

Shut the image down and use the Virtual Box Manager to take a Snapshot of the image. Name the snapshot “v1.0.0 Installed CentOS 6.8 and Virtual Box Guest Additions”

020_vboxmgr_v1-0-0_snapshot

This is it. The image is ready for further work.

Oct 01

I have been quite remiss in the last 5 years or so, with my blog. The software I worked with in that time, and still do, is so vendor-, industry- and use case-specific that it was not really possible to develop blog articles that would be generally applicable, or at least of interest to people other these who work with the software with which I have been working.

Over these years I built a number of virtual machine images which I used to demonstrate the software and solutions. While the software and solutions were pretty point-specific, a lot of the things I did to construct, configure and deliver demonstrations are pretty generic and might be of possible interest to people who likewise need to build demonstration images for infrastructure software and fairly complex solutions that don’t have just a single GUI to demonstrate.

In the, hopefully, series of blogs, I will works through specific aspects of demo image creation and configuration, showing how one can script creation of menus, hotspots, toolbar buttons, screen backgrounds and a bunch of other things. The things which I had to do time and again, and which I endeavoured to script so that I could simply copy and paste text into a terminal window and the objects would be created without having to go through manual configuration using GUIs.

I picked a RedHat 6.8-like OS, CentOS, because I want that flavour and that version of the OS and, most specifically, I want Gnome 2 – not Gnome 3.

Series so far:

  1. Build and Configure the Base Image
    1. Configure Virtual Box Virtual Machine and Install CentOS 6.8 Base Image
    2. CentOS 6.8 – Configure “demo” user for autologin, sudo and VirtualBox Shared Folder access
    3. CentOS 6.8 – Show Detailed Grub Boot Loader Feedback
    4. CentOS 6.8 – Disable Screen Saver and other delays
    5. CentOS 6.8 – Disable Firewall and SELinux Security
    6. CentOS 6.8 – Disable Unneeded Services
    7. CentOS 6.8 – Update DHCP address in /etc/hosts at boot
  2. Configure Working Environment
    1. CentOS 6.8 – Script Adding Top Panel Applets – GEyes, ShowDesktop and Gnome Monitor
    2. CentOS 6.8 – Script adding a new gnome-terminal profile
    3. CentOS 6.8 – Create desktop branding scripts and brand desktop
    4. CentOS 6.8 – Script creating a new demo user
    5. Scripts to hide standard desktop icons and make top and bottom panels hideable
  3. Miscellaneous
    1. Resize Linux Virtual Box Virtual Disk

 

So, watch this space over the next while and see if any of what I will be writing about helps you.

preload preload preload