Nov 20

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.

As I work with the various demonstration images I find myself using gnome-terminal profiles configured to display server logs, scripting interactions and other kinds of stuff using different font sizes, terminal backgrounds and application exit behaviours. I used to configure these manually in each image, then dumping configured profiles into a xml file and loading them into a new image. The gnome-terminal dumps are quite large so this is somewhat cumbersome.

In this post I walk through the method of script-driven addition of gnome terminal profiles and gconftool-2-based configuration so that all of this can be scripted and can avoid the need to do it manually.

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 and on platforms that use gnome-2 desktop.

Discussion

A gnome-terminal profile can be created manually. Just start a gnome-terminal, pull down the Edit menu, choose Profiles and Add new profile. Creating a new profile programmatically is harder.

The following commands will find out what is the “last” profile and will work out what the internal name of the new profile needs to be, then will clone the Default profile and use it to create a new profile, with the new internal and visible names, ready for gconftool-2 configuration.

If you execute these commands you will create a profile.

In the next section you will create scripts which combine all of these commands so that a profile can be created using a single script.

By exporting and manipulating the gnome-terminal global profile list we will determine the name of the “last” profile. This name will either be “Default”, if there is only one, the default profile, or a name of the form “ProfileX”, where X will be 0, 1, 2, …, depending on the number of profiles, in addition to the “Default” profiles, which are configured.

The profile list will look like [Default], or [Default,Profile0], i.e. there will be square brackets surrounding the comma-separated list of names. The sed command will strip the square brackets so that we get just the comma-separated list of names.

profiles_list=$(gconftool-2 --get "/apps/gnome-terminal/global/profile_list" | sed "s|\[||;s|\]||;")
echo "1 Profiles List: " ${profiles_list}

Let’s take the list of profile names, “Default” or “Default,Profile0,Provile1”, etc.. and remove all elements from the list up to and including the last comma. This will leave either the last profile name of the form “ProfileX” or the literal “Default”

last_profile=$(echo "${profiles_list}" | sed "s/^.*,//" | sed 's/Profile//')
echo "Last Profile Name/Number: " ${last_profile}

If the last_profile is the literal “Default” then the “next” internal profile name will be “Profile0” otherwise it will be Profile(X + 1) -> is 2 then Profile3, etc.

Let’s set the “ProfileX” X number to 0 if only default is there or whatever the last is plus 1

if [ ${last_profile} == "Default" ]; then
    next_profile_number=0;
    echo "1 New Profile Number: " ${next_profile_number}
else
    next_profile_number=$(( ${last_profile} + 1 ));
    echo "2 New Profile Number: " ${next_profile_number}
fi
echo "New Profile Number: " ${next_profile_number}

We need to tell gnome that the list of profile names is different. If it was “Default,Profile0” then with the new profile it needs to be “Default,Profile0,Profile1”

Let’s construct profiles list with extra profile “number”

profiles_list=$(echo "[${profiles_list},Profile${next_profile_number}]")
echo "1 Profiles List: " ${profiles_list}

By now we established the new internal profile name – Profile0 or Profile1 or …

Let’s set the new visible profile name as an environment variable for ease of use later

profileName=MyNewProfile

Let’s get a dump of the default profile. We will use it as a template for the new profile

gconftool-2 --dump "/apps/gnome-terminal/profiles/Default" > /tmp/${USER}_gnome-terminal_profiles_${profileName}.xml

Let’s change global name to the new internal profile name in the Default profile dump

sed -i “s|Default|Profile${next_profile_number}|g” /tmp/${USER}_gnome-terminal_profiles_${profileName}.xml

Let’s load the new profile – it will not be useable until the next step is executed

gconftool-2 --load /tmp/${USER}_gnome-terminal_profiles_${profileName}.xml

Let’s tell gnome-terminal that is has another profile by updating the profile_list property

gconftool-2 --set --type list --list-type string "/apps/gnome-terminal/global/profile_list" "${profiles_list}"

Let’s change the visible_name property to the “friendly” name we want to see in the Profiles dropdown

gconftool-2 --set --type string /apps/gnome-terminal/profiles/Profile${next_profile_number}/visible_name "${profileName}"

Let’s set other properties to suit

gconftool-2 --set --type boolean /apps/gnome-terminal/profiles/Profile${next_profile_number}/use_system_font "false"
gconftool-2 --set --type boolean /apps/gnome-terminal/profiles/Profile${next_profile_number}/use_theme_colors "false"
gconftool-2 --set --type boolean /apps/gnome-terminal/profiles/Profile${next_profile_number}/login_shell "true"
gconftool-2 --set --type boolean /apps/gnome-terminal/profiles/Profile${next_profile_number}/default_show_menubar "false"
gconftool-2 --set --type boolean /apps/gnome-terminal/profiles/Profile${next_profile_number}/scrollback_unlimited "true"
gconftool-2 --set --type string /apps/gnome-terminal/profiles/Profile${next_profile_number}/exit_action "hold"
gconftool-2 --set --type string /apps/gnome-terminal/profiles/Profile${next_profile_number}/font "Monospace 14"
gconftool-2 --set --type string /apps/gnome-terminal/profiles/Profile${next_profile_number}/background_color "#FFFFFFFFDDDD"
gconftool-2 --set --type string /apps/gnome-terminal/profiles/Profile${next_profile_number}/foreground_color "#0000FFFF0000"
gconftool-2 --set --type string /apps/gnome-terminal/profiles/Profile${next_profile_number}/scrollbar_position "hidden"

Let’s create a terminal using the profile we just created

gnome-terminal --geometry=80x24+0+0 --profile=${profileName} title "${profileName}" --zoom 0.8 -e "/bin/sh"

The steps above helped us create and configure a new gnome-terminal profile and create a terminal which is using that profile.

Design the “create new gnome-terminal profile” script

cat <<-'EODECK' > /media/sf_distros/scripts/create_new_gnome-terminal_profile.sh
#!/bin/bash
# The following script will find out what is the "last" profile and will work out
# what the internal name of the new profile needs to be, then will clone the Default profile
# and use it to create a new profile, with the new internal and visible names,
# ready for gconftool-2 configuration.

# Let's set the new visible profile name as an environment variable
# for ease of use later

profileName=${1?"Usage: $0 profileName # please provide value for the visible_name profile property - make sure that it is a valid string identifier, i.e consisting of letters and digits only"}

# By exporting and manipulating the gnome-terminal global profile list we will determine
# the name of the "last" profile. This name will either be "Default", if there is only one,
# the default profile, or a name of the form "ProfileX", where X will be 0, 1, 2, …,
# depending on the number of profiles, in addition to the "Default" profiles,
# which are configured.

profiles_list=$(gconftool-2 --get "/apps/gnome-terminal/global/profile_list" | sed "s|\[||;s|\]||;")
echo "1 Profiles List: " ${profiles_list}

# Let's take the list of profile names, "Default" or "Default,Profile0,Provile1", etc..
# and remove all elements from the list up to and including the last comma.
# This will leave either the last profile name of the form "ProfileX" or the literal "Default"

last_profile=$(echo "${profiles_list}" | sed "s/^.*,//" | sed 's/Profile//')
echo "Last Profile Name/Number: " ${last_profile}

# If the last_profile is the literal "Default" then the "next" internal profile name
# will be "Profile0" otherwise it will be Profile(X + 1) -> is 2 then Profile3, etc.
# Let's set the "ProfileX" X number to 0 if only default is there or whatever the last is
# plus 1

if [ ${last_profile} == "Default" ]; then
    next_profile_number=0;
    echo "1 New Profile Number: " ${next_profile_number}
else
    next_profile_number=$(( ${last_profile} + 1 ));
    echo "2 New Profile Number: " ${next_profile_number}
fi
echo "New Profile Number: " ${next_profile_number}

# We need to tell gnome that the list of profile names is different.
# If it was "Default,Profile0" then with the new profile
# it needs to be "Default,Profile0,Profile1"
# Let's construct profiles list with extra profile "number"

profiles_list=$(echo "[${profiles_list},Profile${next_profile_number}]")
echo "1 Profiles List: " ${profiles_list}

# By now we established the new internal profile name - Profile0 or Profile1 or ...

# Let's get a dump of the default profile. We will use it as a template for the new profile

gconftool-2 --dump "/apps/gnome-terminal/profiles/Default" > /tmp/${USER}_gnome-terminal_profiles_${profileName}.xml

# Let's change global name to the new internal profile name in the Default profile dump

sed -i "s|Default|Profile${next_profile_number}|g" /tmp/${USER}_gnome-terminal_profiles_${profileName}.xml

# Let's load the new profile - it will not be useable until the next step is executed

gconftool-2 --load /tmp/${USER}_gnome-terminal_profiles_${profileName}.xml

# Let's tell gnome-terminal that is has another profile by updating the profile_list property

gconftool-2 --set --type list --list-type string "/apps/gnome-terminal/global/profile_list" "${profiles_list}"

# Let's change the visible_name property to the "friendly" name we want to see
# in the Profiles dropdown

gconftool-2 --set --type string /apps/gnome-terminal/profiles/Profile${next_profile_number}/visible_name "${profileName}"

EODECK
chmod ug+x /media/sf_distros/scripts/create_new_gnome-terminal_profile.sh

The following script, given the name of the profile, the data type fo the property to change, the name of the property to change and the value to which to change the property will make the change

cat <<-'EODECK' > /media/sf_distros/scripts/set_profile_property.sh
#!/bin/bash

profileName=${1?"Usage: $0 profileName keyName keyType keyValue # please provide value of the visible_name of the profile whose property you want to change"}
keyName=${2?"Usage: $0 profileName keyName keyType keyValue # please provide name of the profile key which you want to change"}
keyType=${3?"Usage: $0 profileName keyName keyType keyValue # please provide data type of the profile key which you want to change - boolean, string are supported - lists are not"}
keyValue=${4?"Usage: $0 profileName keyName keyType keyValue # please provide value of the profile key which you want to change"}

profileNum=$(gconftool-2 --search-key visible_name | grep ${profileName} | tail -n 1 | sed 's|^.*/Profile||;s|/.*$||')
echo "ProfileNum: " ${profileNum}

gconftool-2 --set --type ${keyType} /apps/gnome-terminal/profiles/Profile${profileNum}/${keyName} "${keyValue}"
EODECK
chmod ug+x /media/sf_distros/scripts/set_profile_property.sh

Create scripts for new profiles very_visble and console_scrolling

The very_visible profile will have larger font (Monospace, 14) and a green background, to distinguish the very_visible terminal from a “regular” gnome-terminal.

cat <<-'EODECK' > /media/sf_distros/scripts/010_make_profile_very_visible.sh
#!/bin/bash
/media/sf_distros/scripts/create_new_gnome-terminal_profile.sh very_visible

/media/sf_distros/scripts/set_profile_property.sh very_visible use_system_font boolean false
/media/sf_distros/scripts/set_profile_property.sh very_visible use_theme_colors boolean false
/media/sf_distros/scripts/set_profile_property.sh very_visible login_shell boolean true
/media/sf_distros/scripts/set_profile_property.sh very_visible default_show_menubar boolean false
/media/sf_distros/scripts/set_profile_property.sh very_visible scrollback_unlimited boolean true
/media/sf_distros/scripts/set_profile_property.sh very_visible exit_action string hold
/media/sf_distros/scripts/set_profile_property.sh very_visible font string "Monospace 14"
/media/sf_distros/scripts/set_profile_property.sh very_visible background_color string "#FFFFFFFFDDDD"
/media/sf_distros/scripts/set_profile_property.sh very_visible foreground_color string "#000000000000"
/media/sf_distros/scripts/set_profile_property.sh very_visible scrollbar_position string hidden
EODECK
chmod ug+x /media/sf_distros/scripts/010_make_profile_very_visible.sh

 

The console_scrolling profile will have larger font (Monospace, 9) and a black background, to distinguish the console_scrolling terminal from a “regular” gnome-terminal.

cat <<-'EODECK' > /media/sf_distros/scripts/011_make_profile_console_scrolling.sh
#!/bin/bash
/media/sf_distros/scripts/create_new_gnome-terminal_profile.sh console_scrolling

/media/sf_distros/scripts/set_profile_property.sh console_scrolling use_system_font boolean false
/media/sf_distros/scripts/set_profile_property.sh console_scrolling use_theme_colors boolean false
/media/sf_distros/scripts/set_profile_property.sh console_scrolling login_shell boolean true
/media/sf_distros/scripts/set_profile_property.sh console_scrolling default_show_menubar boolean false
/media/sf_distros/scripts/set_profile_property.sh console_scrolling scrollback_unlimited boolean true
/media/sf_distros/scripts/set_profile_property.sh console_scrolling scroll_on_output boolean true
/media/sf_distros/scripts/set_profile_property.sh console_scrolling exit_action string hold
/media/sf_distros/scripts/set_profile_property.sh console_scrolling font string "Monospace 9"
/media/sf_distros/scripts/set_profile_property.sh console_scrolling background_color string "#000000000000"
/media/sf_distros/scripts/set_profile_property.sh console_scrolling foreground_color string "#FFFFFFFFFFFF"
/media/sf_distros/scripts/set_profile_property.sh console_scrolling scrollbar_position string hidden
EODECK
chmod ug+x /media/sf_distros/scripts/011_make_profile_console_scrolling.sh

Execute commands to create and configure the two profiles

/bin/bash -v /media/sf_distros/scripts/010_make_profile_very_visible.sh
/bin/bash -v /media/sf_distros/scripts/011_make_profile_console_scrolling.sh

Add to initial bulk configuration script

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 “create gnome-terminal profiles” 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
# create very_visible gnome-terminal profile
/bin/bash -v /media/sf_distros/scripts/010_make_profile_very_visible.sh

# create console_scrolling gnome-terminal profile
/bin/bash -v /media/sf_distros/scripts/011_make_profile_console_scrolling.sh

EODECK
chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh
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 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
preload preload preload