GNC Examples

From GroovixWiki
Jump to: navigation, search

Introduction to GNC

Note: this page assumes knowledge of the GNC script process and it's commands and parameters. Please have a full understanding of the Groovix NetCustomization page before continuing.


Starting a new GNC Script using the GNC template

When you are ready to make your own GNC update, run the following commands in an xterm window to create a copy of the gnc template:
cd /var/www/groovix/gnc/updates/[customer]/
gnc-new [updatename]
where [customer] is your custom groovix version code (GX_VERSION= in /etc/groovix/groovix.conf), and [updatename] is the name of your update. A directory will be created at this new location containing the gnc file necessary to run the update.

Using the gncget command

The directory structure inside each GNC update should be treated as if it is the / (root) directory. When the gncget command is used, it copies and replaces files in the GNC update directory in the same directories as the actual / (root) directory. For example, to replace the /etc/network/interfaces file on a machine, create the interfaces file in a etc/network/ directory under your update directory and use the gncget command gncget --mod=644 /etc/network/interfaces.


Using the apt-get command

  • The groovix-auto-apt-get install command is used to download a package and install it on a local machine. This command can also be used to upgrade an already existing program to the most recent version.
  • The groovix-auto-apt-get remove command is used to remove a program on a local machine.

Examples

Note: each dashed box represents the contents of the gnc file relevant to that script example.


Setting a custom homepage

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --abort '
###############################################################################################################

#Assign the homepage variable of the pac.conf file
bashconfset.pl PAC_BROWSER_STARTUP_HOMEPAGE "[homepage]" /etc/groovix/pac.conf

*Change [homepage] to the desired website you want to use. For example, to use Google, enter http://www.google.com inbetween the quotes.


Setting a custom desktop background

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --skiplive --abort '
###############################################################################################################

#Get custom image, assign read/write permissions, and place it in the proper directory
gncget --mod=644 /var/lib/groovix/pac/images/[desktop_background_image]

*Change [desktop_background_image] to the name of the image file included in the gnc update.


Setting custom screensaver images

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --skiplive --abort '
###############################################################################################################

#Assign the image directory variable of the pac.conf file
bashconfset.pl PAC_CUSTOM_SCREENSAVER_IMAGES_URL_DIR "[ServerIP]/groovix/screensaver/default/" /etc/groovix/pac.conf

*Change [ServerIP] to the IP address of your local Groovix Server. Now, any images uploaded to the directory /groovix/screensaver/default/ on your server will be used in the screensaver slideshow.


Setting a custom welcome message on the login screen

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --abort '
###############################################################################################################

#Assign the welcome message variable of the pac.conf file
bashconfset.pl GDM_WELCOME_MESSAGE "Enter your welcome message here" /etc/groovix/pac.conf


Setting the Acceptable Use Policy page

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --abort '
###############################################################################################################

#Get latest groovix-accept package
apt-get-dontask install groovix-accept

#Assign the acceptable use variable of the pac.conf file to true
bashconfset.pl GK_ACCEPT_USE true /etc/groovix/pac.conf

#Assign the web address of the acceptable use page on the local Groovix Server in the accept.conf file
pyconfset.pl mainurl '[ServerIP]/groovix/accept/acceptable-use.html' /etc/groovix/accept.conf

*Change [ServerIP] to the IP address of your local Groovix Server.


Enabling the web filter

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --abort '
###############################################################################################################

#Install web filter software
apt-get-dontask install groovix-guardian-desktop

#Assign the Groovix Guardian variable of the pac.conf file to true
bashconfset.pl GK_GROOVIXGUARDIAN_ENABLE true /etc/groovix/pac.conf

#Assign the enable filter variable of the cmon.conf file to true
pyconfset.pl enable_gxfilter 1 /etc/groovix/cmon.conf


Whitelisting a website

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --abort '
###############################################################################################################

#Assign addresses to the whitelist variable of the pac.conf file
bashconfset.pl GK_SITE_WHITELIST '[website],[website]' /etc/groovix/pac.conf

*Change [website] to the domain, not the page of the site you would like to allow through the filter. Example, test.com, or example.test.com. To add multiple entries, separate with commas. If updating the whitelist with a new GNC script, all prior entries need to be included with the new entries.


Adding sites to the DansGuardian blacklist & whitelist

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --skiplive --abort '
###############################################################################################################

#Assign addresses to the bannedsitelist file used by Groovix Guardian
echo '[website]' >> /etc/dansguardian/lists/bannedsitelist

#Assign addresses to the exceptionsitelist file used by Groovix Guardian
echo '[website]' >>  /etc//dansguardian/lists/exceptionsitelist

*Change [website] to the domain, not the page of the site you would like to allow through the filter. Example, test.com, or example.test.com.


Configuring a Reservation Station machine

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --abort '
###############################################################################################################

#Assign customer username and password variables of the pacrez.conf file
pyconfset.pl customid [username] /etc/groovix/pacrez.conf
pyconfset.pl custompw [password] /etc/groovix/pacrez.conf

#Assign the local Groovix Server variable of the pacrez.conf file
pyconfset.pl pacrezserver '[ServerIP]/groovix/pacrez/python/user_access.py' /etc/groovix/pacrez.conf

#Enable pacrez variables to true for pacauth.conf, cmon.conf, and pac.conf files
pyconfset.pl enablepacrez 1 /etc/groovix/pacauth.conf
pyconfset.pl enablepacrez 1 /etc/groovix/cmon.conf
bashconfset.pl GK_PACREZ_ENABLE true /etc/groovix/pac.conf

*Change [username] and [password] to the name and password used by your custom Groovix configuration. View the Contact Information page if you need assistance with getting this information. *Change [ServerIP] to the local IP address of your Groovix Server.


Catalog only/kiosk machine

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --abort '
###############################################################################################################

#Assign variable to allow screensaver to run in session
bashconfset.pl SAKLOCKSAVER_RUN_IN_USER_SESSION true /etc/groovix/pac.conf

#Cycle screensaver/logout every 20 minutes
bashconfset.pl GK_LOGOUT_TIME 20 /etc/groovix/pac.conf
sed -i 's/*cycle:.*/*cycle:   0:20:00/' /etc/X11/app-defaults/XScreenSaver

bashconfset.pl GK_PACREZ_ENABLE false /etc/groovix/pac.conf
pyconfset.pl enablepacrez 0 /etc/groovix/pacauth.conf
pyconfset.pl enablepacrez 0 /etc/groovix/cmon.conf

#Add catalog user
NEWUSER=catalog
adduser --disabled-login --gecos "Infostation Access" $NEWUSER
addgroup $NEWUSER audio
addgroup $NEWUSER plugdev

#Prevent SIP and guest logins from working
pyconfset.pl localauthonly 1 /etc/groovix/pacauth.conf

#Enable logout when Firefox is closed
bashconfset.pl GK_FIREFOX_CLOSE_LOGOUT true /etc/groovix/pac.conf

bashconfset.pl GDM_TIMED_LOGIN_ENABLE true /etc/groovix/pac.conf
bashconfset.pl GDM_TIMED_LOGIN_USER catalog /etc/groovix/pac.conf
bashconfset.pl GDM_TIMED_LOGIN_DELAY 1 /etc/groovix/pac.conf

#Disable acceptable use prompt
bashconfset.pl GK_ACCEPT_USE false /etc/groovix/pac.conf


Setting a custom user profile

Follow the steps on the "Making changes to the user profile" section of the Groovix Profiles page before continuing

###############################################################################################################
GNC_PARAMETERS=' --runonce  --abort '
###############################################################################################################

#Get, unzip, and place profile cpio file
gncget --gunzip --mod=644 /var/lib/groovix/pac/home/template.cpio


Downloading large files with a random delay

###############################################################################################################
GNC_PARAMETERS=' --runonce --abort '
###############################################################################################################

#Create random delay so download is staggered across multiple machines
MAX_RANDOM_DELAY=10
MY_DELAY=$[ ( $(head -c4 /dev/urandom | od -t u4 | awk '{ print $2 }') % $MAX_RANDOM_DELAY ) ]
echo "Waiting $MY_DELAY seconds before downloading new cpio"
sleep $MY_DELAY

#Get, unzip, and place profile cpio file
gncget --mod=644 --gunzip /var/lib/groovix/pac/home/custom.cpio


Setting up or changing printers

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall '
###############################################################################################################

#Output machine type and assign it to the MYTYPE variable
MYTYPE=`cat /etc/groovix/type`
echo MYTYPE is $MYTYPE

#If statement to apply printer setup to specific machine types
if [ $MYTYPE = "[reservation]" ] ; then
        echo "printers for reservations stations handled manually"
else
	#Stop CUPS service, otherwise config files will be overwritten
	/etc/init.d/cups stop

	#Clear CUPS cache
	set +e
	rm -f /var/cache/cups/*.ipp
	set -e

	#Get and place printers.conf file and printer .ppd files
	gncget --mod=644 /etc/cups/printers.conf
	gncget --mod=644 /etc/cups/ppd/black_and_white.ppd
	gncget --mod=644 /etc/cups/ppd/color.ppd
	gncget --mod=644 /etc/cups/ppd/childrens.ppd
	
	#Restart CUPS
	/etc/init.d/cups start
	
#end if statement
fi

*Change [reservation] with the name for your Reservation Station machine type, change [date] to date of the backup.


Setting custom shutdown delays and shutdown times

###############################################################################################################
GNC_PARAMETERS=' --runonce --skipinstall --abort '
###############################################################################################################

#Assign shutdown and end of day logoff variables to the pac.conf and netcustomization.conf files
bashconfset.pl SHUTDOWN_UPDATE_DELAY [time] /etc/groovix/netcustomization.conf

#Assign time, in minutes, before shutdown to display first warning message
bashconfset.pl PAC_SHUTDOWN_WARNING_DELAY [time] /etc/groovix/pac.conf

#Assign context of first warning message
bashconfset.pl PAC_SHUTDOWN_WARNING_MESSAGE 'You have 10 minutes remaining until this computer shuts down. 
Please be sure to print and save your work or it will be lost.' /etc/groovix/pac.conf

#Assign time, in minutes, before shutdown to display final warning message
bashconfset.pl PAC_SHUTDOWN_LAST_WARNING_DELAY [time] /etc/groovix/pac.conf

#Assign context of final warning message
bashconfset.pl PAC_SHUTDOWN_LAST_WARNING_MESSAGE 'You have 5 minutes remaining until this computer shuts down. 
Please be sure to print and save your work or it will be lost.' /etc/groovix/pac.conf

#Clear out old entries of /etc/crontab file
perl -ni -e 'print unless /groovix-shutdown-procedure/' /etc/crontab

#Set shutdown schedule in /etc/crontab file
#Set 8:50pm shutdown for Monday-Friday
echo '50 20 * * 1,2,3,4,5 root groovix-shutdown-procedure --update --shutdown' >> /etc/crontab
#Set 5:50pm shutdown for Saturday and Sunday
echo '50 17 * * 6,7 root groovix-shutdown-procedure --update --shutdown' >> /etc/crontab

*Change [time] to the amount of time, in minutes, set for the delay; follow up with the letter 'm'. Example, for 5 minutes use 5m. For more information on setting custom time settings in the crontab file, see the Other How-Tos section of the Administrators Guide.