License

Copyright (C) 2008-2017 Oliver Bohlen.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.

A copy of the license is included in the section entitled "GNU Free Documentation License".

Introduction

This documentation comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.

Howto: Thinclient - Basesystem for Gentoo Linux

Here a little documentation how I installed the basesystem for my thinclients. The special thing of these clients is that they are booted from a read only nfs filesystem. The goal of this is that the system can be booted at the same time from more different computers.

I installed it in a chroot on my Server. You can use the Gentoo Handbook for the basic installation. Here are some changes I used to make it to a read only thinclient.
This is the profile I use:

rm /etc/make.profile
ln -s /usr/portage/profiles/default/linux/x86/2008.0/desktop /etc/make.profile

I installed some additional software for me and my users. Here is what I installed:
chroot /srv/thinclient/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && emerge app-arch/p7zip sys-apps/sdparm sys-apps/hdparm app-arch/unace app-arch/unarj app-arch/unlzx app-arch/rar app-arch/arj app-arch/lha app-arch/unadf app-misc/mc app-cdr/k3b app-editors/vim app-office/openoffice app-portage/genlop app-portage/gentoolkit app-text/acroread dev-util/strace media-sound/alsa-tools media-sound/alsa-utils media-sound/musescore media-sound/timidity++ media-video/dvdrip net-im/licq net-wireless/ipw2100-firmware net-wireless/ipw2200-firmware sys-kernel/gentoo-sources sys-libs/libstdc++-v3 sys-process/vixie-cron virtual/libstdc++ www-client/mozilla-firefox www-plugins/adobe-flash sys-power/acpid app-laptop/radeontool sys-fs/dosfstools app-text/unix2dos app-text/dos2unix net-analyzer/nmap net-misc/netkit-telnetd sys-apps/parted sys-block/gparted mail-client/mozilla-thunderbird net-wireless/bluez-firmware net-wireless/bluez-hcidump sys-apps/ethtool sys-kernel/linux-firmware media-gfx/gimp net-misc/rdate net-misc/ntp net-nds/yp-tools net-nds/ypbind app-emulation/wine sys-process/htop media-video/kino media-sound/audacity games-action/chromium net-print/foomatic-filters-ppds net-im/skype net-analyzer/iptraf app-mobilephone/wammu app-mobilephone/gnokii net-fs/curlftpfs sys-fs/sshfs-fuse net-fs/fusesmb sys-power/acpid app-office/qbankmanager app-office/grisbi app-cdr/xfburn x11-terms/terminal app-editors/mousepad app-office/orage media-gfx/ristretto media-sound/grip media-gfx/gqview media-plugins/mytharchive media-plugins/mythbrowser media-plugins/mythcontrols media-plugins/mythflix media-plugins/mythgallery media-plugins/mythgame media-plugins/mythmovies media-plugins/mythmusic media-plugins/mythnews media-plugins/mythphone media-plugins/mythvideo media-plugins/mythweather media-plugins/mythzoneminder dev-python/imdbpy net-im/pidgin media-sound/tagtool media-sound/audacious media-plugins/audacious-plugins media-plugins/audacious-xosd x11-themes/audacious-themes app-arch/xarchiver media-gfx/inkscape app-office/dia app-misc/fdupes dev-util/geany net-misc/openvpn media-sound/id3v2 media-libs/exiftool dev-perl/MP3-Tag'

If you want to use this solution you need the following howto(s) finished:

Required software

The required software has to be installed with the following command(s):
chroot /gtc/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && emerge app-admin/rsyslog'
chroot /gtc/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && emerge net-fs/nfs-utils'

Changes in /etc/cron.weekly/gtcupdate

File permissions:
Owner: root
Group: root
Permissions: -rwx------

Click here for a download of the complete file: /etc/cron.weekly/gtcupdate

Changed on 05.01.09
Issued by olli
Beginning line 2

Update the thinclient system automatically once a week

#!/bin/bash

# Update Hibiscus
ARCH=`uname -m | grep -o '64'`
JAMEICAVERSION=`wget -q -O - http://www.willuhn.de/products/jameica/releases/version-nightly`
HIBISCUSVERSION=`wget -q -O - http://www.willuhn.de/products/hibiscus/releases/version-nightly`
cd /tmp
#wget http://www.willuhn.de/products/jameica/releases/current/jameica/jameica-linux.zip
wget http://www.willuhn.de/products/jameica/releases/nightly/jameica-${JAMEICAVERSION}-nightly-linux${ARCH}.zip
#wget http://www.willuhn.de/products/hibiscus/releases/current/hibiscus.zip
wget http://www.willuhn.de/products/hibiscus/releases/nightly/hibiscus-${HIBISCUSVERSION}-nightly.zip
#hibiscusfile="hibiscus.zip"
#jameicafile="jameica-linux.zip"
jameicafile="jameica-${JAMEICAVERSION}-nightly-linux${ARCH}.zip"
hibiscusfile="hibiscus-${HIBISCUSVERSION}-nightly.zip"

cd /opt
rm -rf /opt/jameica
unzip /tmp/${jameicafile}
cd jameica/plugins
unzip /tmp/${hibiscusfile}

for umg in stable test
do
 cd /gtc/$umg/opt
 rm -rf /gtc/$umg/opt/jameica
 unzip /tmp/${jameicafile}
 cd jameica/plugins
 unzip /tmp/${hibiscusfile}
 echo -e "[Desktop Entry]\n"\
"Name=Hibiscus\n"\
"Comment=Hibiscus die freie Homebanking-Anwendung\n"\
"Exec=/opt/jameica/jameica.sh\n"\
"Terminal=false\n"\
"Encoding=UTF-8\n"\
"Type=Application\n"\
"Icon=/opt/jameica/jameica-icon.png\n"\
"Categories=Office,Finance\n"\
> /gtc/$umg/usr/share/applications/Hibiscus.desktop
done
cat /gtc/test/usr/share/applications/Hibiscus.desktop >/usr/share/applications/Hibiscus.desktop
rm /tmp/${jameicafile}
rm /tmp/${hibiscusfile}

# Update GTC
echo "chroot /gtc/test /bin/bash -c '

echo -e \"\n\n\n---- PREPARING ENVIRONMENT ----\n\"
env-update &>/dev/null && source /etc/profile && \
mount -t proc proc /proc >/dev/null 2>&1
mount shm -t tmpfs /dev/shm >/dev/null 2>&1
mount sys -t sysfs /sys >/dev/null 2>&1
chmod 1777 /dev/shm
chmod 666 /dev/urandom

echo -e \"\n\n\n---- EMERGE SYNC ----\n\"
emerge --sync -q && \

echo -e \"\n\n\n---- WORLD UPDATE ----\n\"
emerge -uqDvN --with-bdeps=y --keep-going @world

echo -e \"\n\n\n---- ADDITIONAL SOFTWARE ----\n\"
gtc-additional-sw-del
gtc-additional-sw-add

echo -e \"\n\n\n---- REVDEP-REBUILD ----\n\"
emerge @preserved-rebuild -1qv --keep-going
rm /var/cache/revdep-rebuild/*.rr
revdep-rebuild -i -C -- -1qv --keep-going

echo -e \"\n\n\n---- PYTHON-UPDATER ----\n\"
python-updater --disable-manual -- -1qv --keep-going

echo -e \"\n\n\n---- PERL-CLEANER ----\n\"
perl-cleaner --all -- -1qv --keep-going | grep -v \" : /usr/lib/perl\" | grep -v \" -> \" | grep -i -v \"^Skipping directory\"

echo -e \"\n\n\n---- PKG CHECK ----\n\"

equery -N -C check -o '*' 2>&1 |  grep \"^!!!\" | egrep -vi \"^!!! /etc|does not exist|/cfg.pyc|/var/spool/at/atjobs/.SEQ|has wrong mtime|flash.+does not point to|/usr/lib/vlc/plugins/plugins.dat|/usr/lib/openoffice/program/soffice.bin|/opt/netscape/plugins/nppdf.so|/usr/share/texmf/tex/generic/config/language.\"

echo -e \"\n\n\n---- Clean up ----\n\"
rm -r /var/tmp/portage/*
rm -r /usr/portage/distfiles/*

' >/tmp/gtc-update 2>&1 ; cat -v /tmp/gtc-update | mail -s 'GTC-Update' admin" | at now >/dev/null

Changes in /gtc/test/etc/conf.d/hostname

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/conf.d/hostname

Changed on 05.01.09
Issued by olli
Beginning line 2

This sets a default hostname to the thinclient


Before change
hostname="localhost"
After change
hostname="gtc-default.gtc-domain"

Changes in /gtc/test/etc/conf.d/sshd

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/conf.d/sshd

Changed on 28.11.12
Issued by olli
Beginning line 23

Do not start dhcp at boot

rc_need="!net"

Changes in /gtc/test/etc/crontab

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/crontab

Changed on 19.07.13
Issued by olli
Beginning line 18

System health checks

# Check Disk Usage
*/5 * * * *    root     [ -e /etc/thinclient/scripts/check-hdd.sh ] && /etc/thinclient/scripts/check-hdd.sh
30 * * * *     root	rm -rf /tmp/df-?d??
# Check Memory
*/5 * * * *    root     [ -e /etc/thinclient/scripts/check-mem.sh ] && /etc/thinclient/scripts/check-mem.sh
# Check Swap
*/5 * * * *    root     [ -e /etc/thinclient/scripts/check-swap.sh ] && /etc/thinclient/scripts/check-swap.sh
# Check temperature
*/5 * * * *    root     [ -e /etc/thinclient/scripts/check-temperature.sh ] && /etc/thinclient/scripts/check-temperature.sh
# Check time
*/5 * * * *    root     ntpdate -s 0.de.pool.ntp.org >/dev/null 2>&1 || ntpdate -s 1.de.pool.ntp.org >/dev/null 2>&1

Changes in /gtc/test/etc/dhcpcd.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/dhcpcd.conf

Changed on 30.10.09
Issued by after
Beginning line 40

Timeout for dhcpcd

timeout 20

Changes in /gtc/test/etc/distcc/hosts

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/distcc/hosts

Changed on 30.11.09
Issued by after
Beginning line 6

The Hosts with distccd. You need this ony if you use distcc


Before change
127.0.0.1
After change
think-gabosh.example.com
backup-gabosh.example.com
ion-gabosh.example.com
proll-gabosh.example.com

Changes in /gtc/test/etc/init.d/checkroot

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/init.d/checkroot

Changed on 19.03.10
Issued by olli
Beginning line 10

This stops remounting/mounting the root. Mounting stuff for is done in the initrd.

if cat /proc/cmdline | grep -i root=/dev/nfs >/dev/null
then
 exit 0
fi

Changes in /gtc/test/etc/local.d/gtc.start

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/local.d/gtc.start

Changed on 09.10.09
Issued by olli
Beginning line 1

Configure the Thinclient

/etc/thinclient/startup/gtc-startupconfig 2>&1 | tee -a /var/log/thinclient.log
/etc/init.d/xdm zap >/dev/null 2>&1

Changes in /gtc/test/etc/local.d/gtc.stop

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/local.d/gtc.stop

Changed on 19.09.12
Issued by olli
Beginning line 2

Store Passwords and Mixer settings if the BGTC is local

#!/bin/bash
if mount | grep "/_gtcroot type nfs" >/dev/null
then
 echo "This GTC networt booted"
else
 . /etc/thinclient/scripts/gtc-confs.sh
 mkdir -p /_gtcroot/etc/thinclient/profiles/`hostname`/local
 echo "Saving mixersettings"
 alsactl store -f /_gtcroot/etc/thinclient/profiles/`hostname`/local/mixersettings
 echo "Saving passwords"
 cat /etc/shadow | grep -a "^root" > /_gtcroot/etc/thinclient/profiles/`hostname`/local/shadow
 for LU in $LOCALUSER
 do
  cat -vT /etc/shadow | grep -a "^$LU" >> /_gtcroot/etc/thinclient/profiles/`hostname`/local/shadow
 done
fi

Changes in /gtc/test/etc/make.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/make.conf

Changed on 01.12.08
Issued by olli
Beginning line 4

Some settings to get a maximum of compatibility of the system software


Before change
#CFLAGS=""
After change
USE="mysqli pcre16 video svc lv2 webserver winbind client fluidsynth portaudio stk vst gnome-keyring postproc ruby_targets_ruby21 bluray dlz jack id3tag ladspa libsamplerate sbsms soundtouch twolame vamp fdk x265 ffmpeg -libav matroska libass resolvconf networkmanager image-converter pidgin sensord nscd extensions gbm -tls-heartbeat utils vala curl_ssl_nss eds orc glib gdbm caps pulseaudio equalizer sip icq messages vpx upnp java videos nocd hog mvl taglib vte udev dbus server ssh -hylafax odf xa libkms doom heretic hexen minizip timidity ntfsprogs mdadm btrfs pcmcia hwdb kerbros gssapi inotify mdev nfs icu wps hpijs lxde dynamic syncmai xetex xcomposite consolekit amr perl python madwifi apng xmlrpc -ole -google -galago openldap bash-completion podcast youtube theora mjpeg vlc hddtemp -additions fontconfig lame -handbook -vaapi css analogtv dolbyinrec dvbplayer dvbsetup dvdarchive setup softosd gimp emerald gd mdnsresponder-compat lightning gallium epiphany wmf beagle firefox thunderbird mono vcdinfo vcdx wma-fixed cjk unicode ivtv mixer tv kdrive gdu fax xrandr sasl threads hash apache2 syslog overlays -tcpd -minimal sdb-ldap qemu-ifup vde gstreamer policykit ofx sqlite redland gnokii acl xattr extras desktopglobe akonadi semantic-desktop cdda ipod lastfm -embedded socks5 groupwise winpopup yahoo oscar msn skype nis mng sql webkit dmraid fat hfs reiser4 device-mapper jfs ntfs reiserfs xfs irda lm_sensors musicbrainz midi visualization acl xattr netboot vim-syntax laptop chipcard hbci 3dnow 3dnow ext a52 audiofile cddb cdio cdparanoia curl dri dvb fuse nsplugin templates -kde cdr dvd dvdr cairo networking guile gtk gtk2 -gnome 7zip acpi alsa arts imagemagick joystick jpeg jpeg2k ldap lirc lzo mysql mp3 mplayer mpeg mmx mmxext mad musepack mythtv nas ogg opengl openal pvr png ppds quicktime radio rar svg sse sse2 ssse3 samba scanner sndfile sdl sms teletext tiff tse3 usb v4l v4l2 vdr vorbis win32codecs X xcomposite xine xinerama xscreensaver xv xvid x264 aac faac opus"
CPU_FLAGS_X86="mmx mmxext sse sse2 sse3"
#LIGHTDM_GREETER="lightdm-gtk-greeter"
ACCEPT_LICENSE="-* @BINARY-REDISTRIBUTABLE MPEG-4 DES myspell-et_EE-IEL myspell-lt_LT-AlbertasAgejevas gccmakedep imake xf86rushproto freedist myspell-ru_RU-ALexanderLebedev MSttfEULA gSOAP CCPL-ShareAlike-1.0 xf86bigfontproto Ximian-logos LDP-1a JasPer2.0 X11 LPPL-1.3b unRAR free-noncomm CCPL-Sampling-Plus-1.0 LIBGLOSS NEWLIB CC-Sampling-Plus-1.0 as-is bluez-firmware BUILDLIC D1X LOKI-EULA icaclient PUEL FraunhoferFDK MakeMKV-EULA AdobeFlash-11.x"
LANG="de_DE"
LANGUAGE="41"
LINGUAS="en de"
L10N="en de"
CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 ssse3"
#LINGUAS="en de ru fr nds"
#INPUT_DEVICES="keyboard mouse joystick virtualbox synaptics evdev"
INPUT_DEVICES="synaptics evdev"
VIDEO_CARDS="i915 i965 intel nouveau r100 r200 r300 r600 radeon vmware apm ark ast cirrus epson fbdev glint i128 i740 mach64 modesetting nv r128 savage siliconmotion sis tdfx trident v4l vesa via MakeMKV-EULA amdgpu radeonsi"
APACHE2_MPMS="worker"
CURL_SSL="nss"
GRUB_PLATFORMS="efi-32 efi-64 pc qemu xen"

Changes in /gtc/test/etc/portage/package.keywords

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/portage/package.keywords

Changed on 01.12.08
Issued by olli
Beginning line 1

Demask some packages


# Noteedit
=media-sound/musescore-1.3 ~x86

# System tools
=app-crypt/chntpw-140201 ~x86
=sys-boot/os-prober-1.65

=net-misc/remmina-1.2.0_rc3 ~x86

# Firefox
<www-client/firefox-46 ~x86

# wine/playonlinux
=games-action/d2x-rebirth-0.58.1 ~x86
=games-fps/serious-sam-tfe-1_beta3 ~x86
=app-emulation/playonlinux-4.2.6 ~x86
=games-fps/serious-sam-tse-1_beta1 ~x86
<app-emulation/wine-1.9 ~x86

=app-text/tesseract-3.04.00-r3 ~x86

# Android adb
=dev-util/android-sdk-update-manager-22.3 ~x86
=dev-util/android-tools-0_p20130218 ~x86
=app-mobilephone/heimdall-9999 **

=net-nds/phpldapadmin-1.2.3-r1 ~x86

=net-libs/libtirpc-0.2.4-r2 ~x86
=dev-python/pexpect-3.3 ~x86

# icaclient
=net-misc/icaclient-XXX.XXX.XXX.XXX-r1 ~x86

# vBox
#=x11-drivers/xf86-video-virtualbox-4.2.24 ~x86

# lmms (Audacity-Alternative)
=media-sound/lmms-1.1.3 ~x86
=media-libs/stk-4.5.0 ~x86

# Handbrake
=media-video/handbrake-0.10.5-r2 ~x86
=media-video/ffmpeg-2.6.3 ~x86
=media-video/mplayer-1.2_pre20150214 ~x86
=media-libs/libde265-0.9 ~x86
=media-libs/x265-1.8-r3 ~x86

# Makemkv
=media-video/makemkv-1.10.4 ~x86

# kodi
=media-tv/kodi-14.1 ~x86

# Bluetooth
=net-wireless/blueman-2.0.3 ~x86

# ardour
=media-libs/rubberband-1.8.1-r1 ~x86
=media-sound/ardour-5.5 ~x86
media-plugins/calf ~x86
=media-libs/suil-0.8.2 ~x86

# linphone
=net-voip/linphone-3.6.1 ~x86
=net-libs/libeXosip-4.0.0 ~x86

# lightspark
=www-plugins/lightspark-0.7.2_p20150318 ~x86

# required by sys-boot/refind (argument)
=sys-boot/udk-2015 ~x86
# # required by sys-boot/refind (argument)
=sys-boot/refind-0.10.4-r2 ~x86

Changes in /gtc/test/etc/postfix/main.cf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/postfix/main.cf

Changed on 02.07.12
Issued by olli
Beginning line 681

Mailsettings

inet_protocols = ipv4
myorigin = $myhostname
mydestination =
relay_domains = $myhostname
relayhost = $mydomain
local_recipient_maps =
inet_interfaces = loopback-only
local_transport = error:local delivery is disabled

Changes in /gtc/test/etc/ssh/sshd_config

File permissions:
Owner: root
Group: root
Permissions: -rw-------

Click here for a download of the complete file: /gtc/test/etc/ssh/sshd_config

Changed on 05.01.09
Issued by olli
Beginning line 167

Some SSh-Settings

MACs hmac-sha1,umac-64@openssh.com,hmac-ripemd160
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128
PermitRootLogin yes

Changes in /gtc/test/etc/thinclient/scripts/check-hdd.sh

File permissions:
Owner: root
Group: root
Permissions: -rwxr-x---

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/check-hdd.sh

Changed on 19.07.13
Issued by olli
Beginning line 1

Cron-Check Script for disk usage

#!/bin/bash
df -l /dev/?d?? 2>/dev/null | grep "^/dev/" | perl -pe 's/[ \%]+/ /g' | cut -d" " -f1,5 2>/dev/null | while read i
do  
 disk=`echo $i | cut -d" " -f1 | cut -d"/" -f3`
 usa=`echo $i | cut -d" " -f2`
 lock="/tmp/df-$disk"
 if [ $usa -gt 95 ]
 then
  if [ -f $lock ]
  then 
   date >>$lock
  else 
   echo -e "Disk usage $disk at $usa%:\n`df -l /dev/?d?? | grep $usa\%`\n\n `ps aux`\n\n`free -m`" | mail -s "`hostname`: Disk usage $disk at $usa% - CRITICAL" `ls -1 /home/ | while read m; do echo -n $m,; done`root
   date >$lock
  fi
 else 
  if [ -f $lock ]
  then 
   echo -e "Disk usage $disk at $usa%:\n`cat $lock`" | mail -s "`hostname`: Disk usage $disk at $usa% - OK" `ls -1 /home/ | egrep -v 'lost+found' | while read m; do echo -n $m,; done`root
   rm -f $lock
  fi
 fi
done

Changes in /gtc/test/etc/thinclient/scripts/check-mem.sh

File permissions:
Owner: root
Group: root
Permissions: -rwxr-x---

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/check-mem.sh

Changed on 19.07.13
Issued by olli
Beginning line 2

Cron Check script for memory usage

#!/bin/bash
mem=`free -m | grep "^Mem:" | perl -pe 's/[ ]+/ /g' | cut -d" " -f 4`
if [ $mem -lt 32 ]
then 
 if [ -f "/tmp/memlow" ]
 then
  echo "`date` --> $mem" >>/tmp/memlow
 else
  echo -e "Free Mem low ($mem MB):\n`free -m`\n\n`ps aux`" | mail -s "`hostname`: Free mem low ($mem MB)" `ls -1 /home/ | egrep -v 'lost+found' | while read m; do echo -n $m,; done`root 
  echo "`date` --> $mem" >>/tmp/memlow
 fi
else
 rm -f /tmp/memlow
fi


Changes in /gtc/test/etc/thinclient/scripts/check-swap.sh

File permissions:
Owner: root
Group: root
Permissions: -rwxr-x---

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/check-swap.sh

Changed on 19.07.13
Issued by olli
Beginning line 2

Cron Check script for swap usage

#!/bin/bash
blkid | grep GTCSWAP >/dev/null || exit 0
if [ `free -m | grep "^Swap:" | perl -pe 's/[ ]+/ /g' | cut -d" " -f 4` -lt 64 ]
then 
 echo -e "Free Swap low:\n`free -m`\n\n`ps aux`" | mail -s "`hostname`: Free swap low (under 256MB)" `ls -1 /home/ | egrep -v 'lost+found' | while read m; do echo -n $m,; done`root
fi

Changes in /gtc/test/etc/thinclient/scripts/check-temperature.sh

File permissions:
Owner: root
Group: root
Permissions: -rwxr-x---

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/check-temperature.sh

Changed on 19.07.13
Issued by olli
Beginning line 2

Cron Check script for system temperature sensors

#!/bin/bash
ls -1 /sys/devices/platform/coretemp.0/temp*_input >/dev/null 2>&1 || exit 0
for sensor in `ls -1 /sys/devices/platform/coretemp.0/temp*_input`
do
 sens=`basename $sensor`
 if [ `cat $sensor` -gt 85000 ]
 then 
  if [ -f /tmp/sensor-$sens ]
  then 
   date >>/tmp/sensor-$sens
  else 
   let temp=`cat $sensor`/1000
   echo -e "Temperature of $sens up to $temp degree Centigrade...\n\n`ps aux`\n\n`free -m`\n\n`df -lh | cat -vT `" | cat -vT | mail -s "`hostname`: Temperature up to $temp degree Centigrade" `ls -1 /home/ | egrep -v 'lost+found' | while read m; do echo -n $m,; done`root
  date >/tmp/sensor-$sens
  fi
 else 
  if [ -f /tmp/sensor-$sens ]
  then 
   let temp=`cat $sensor`/1000
   echo -e "Temperature OK - $temp degree Centigrade...\n\n`cat /tmp/sensor-$sens`" | mail -s "`hostname`: Temperature OK again $temp" `ls -1 /home/ | egrep -v 'lost+found' | while read m; do echo -n $m,; done`root
   rm -f /tmp/sensor-$sens
  fi
 fi
done

Changes in /gtc/test/etc/thinclient/scripts/gtc-additional-sw-add

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-additional-sw-add

Changed on 15.02.10
Issued by olli
Beginning line 2

This script installs additional/optional software defined in the thinclient.conf[.local]

#!/bin/bash

# Insert make.conf
source /etc/make.conf

source /etc/thinclient/scripts/gtc-confs.sh

# Mount proc for compiling
mount -t proc proc /proc 2>/dev/null 

# Create /_additionalsw-Dir and remove possible old DB entries
if [ ! -d /_additionalsw ] 
then 
 mkdir -p /_additionalsw
 chmod 0755 /_additionalsw
 for i in `echo $PACKAGES`
 do
  if [ -d /var/db/pkg/$i* ]
  then
   rm -r /var/db/pkg/$i*
  fi
 done
fi

# Link package database
if [ ! -L /_additionalsw/var/db/pkg ]
then
 mkdir -p /_additionalsw/var/db/
 ln -sf /var/db/pkg /_additionalsw/var/db/pkg
fi
mkdir -p /_additionalsw/var/cache/edb
ln -sf /var/cache/edb/counter /_additionalsw/var/cache/edb/counter

# Optionally source a user defined script for doing things before emerge
if [ -f "/etc/gtc-preupdate.sh" ]
then
 . /etc/gtc-preupdate.sh
fi

# Install the packages in an other root
KERNEL_DIR="/usr/src/linux" ACCEPT_LICENSE="*" ROOT="/_additionalsw" emerge -uq --keep-going --config-root=/ $PACKAGES

# Remove probably old links
echo "Searching for old /_additionalsw-SymLinks"
for i in `find / -xdev -type l -printf "%h/%f;%l\n" | grep ";/_additionalsw/" | cut -d";" -f1`
do
 echo "Removing old /_additionalsw-SymLink $i"
 rm $i
done

# Search for nonexisting directories
find /_additionalsw -type d | sed 's/^\/_additionalsw//' | while read i
do
 if [ ! -e "$i" ]
 then
  echo "Linking Directory $i"
  ln -s "/_additionalsw$i" "$i"
 fi
done

# Search for nonexisting files
find /_additionalsw -type f | sed 's/^\/_additionalsw//' | while read i
do
 if [ ! -e "$i" ]
 then
  echo "Linking File $i"
  ln -s "/_additionalsw$i" "$i"
 fi
done

# Search for nonexisting links
find /_additionalsw -type l | sed 's/^\/_additionalsw//' | while read i
do
 if [ ! -e "$i" ]
 then
  echo "Linking Link $i"
  ln -s "/_additionalsw/$i" "$i"
 fi
done

echo "Running some environment-updates"
env-update
source /etc/profile
depmod -a
ldconfig

echo "Putting the packages into the world-file"
ACCEPT_LICENSE="*" emerge -nq $PACKAGES

echo "

The following packages have been linked in: $PACKAGES"


Changes in /gtc/test/etc/thinclient/scripts/gtc-additional-sw-del

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-additional-sw-del

Changed on 15.02.10
Issued by olli
Beginning line 2

This script deletes all additional/optional installed software


Before change
#!/bin/bash

source /etc/thinclient/scripts/gtc-confs.sh

echo "Cleaning world file"
emerge --deselect $PACKAGES
echo "Cleaning portage"
emerge --depclean 

echo "Searching for /_additionalsw-SymLinks"
find / -xdev -type l -printf "%h/%f;%l\n" | grep ";/_additionalsw" | cut -d";" -f1 | while read i
do
 echo "Removing SymLink $i"
 rm "$i"
done

echo "Deleting /_additionalsw"
rm -r /_additionalsw

Changes in /gtc/test/etc/thinclient/scripts/gtc-buildkernel

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-buildkernel

Changed on 08.10.09
Issued by olli
Beginning line 3

Command for creating kernel, modules, initrd with uuid-Support,... for the thinclient.

#!/bin/bash

# Get script name
script=`basename $0`

if [ $script = "gtc-buildkernel-menuconfig" ]
then
 echo "Before Running this script link the correct Kernel-Version in /usr/src/ to /usr/src/linux!!!

While running \"make menuconfig\" (in this script) please enable the following drivers:

[ ] 64-bit kernel

Processor type and features --->
 High Memory Support (64GB)

Device Drivers  --->
 Network device support ->
  Wireless LAN ->
   ### Alle m&ouml;glichen WLAN-Karten, die ggf. Gebraucht werden ausw&auml;hlen  (Atheros, Realtek, USB,...)

Kernel hacking  --->
 <*> Memtest

ENTER for continue; Ctrl+C to abort"
 read x
 # Generate kernel, initrd ans System.map
 genkernel all --disklabel --no-mrproper --menuconfig --no-zfs --no-lvm --no-mdadm --no-dmraid --no-multipath --no-iscsi --no-luks --no-gpg --no-unionfs --no-firmware
fi
if [ $script = "gtc-buildkernel" ]
then
 genkernel all --disklabel --no-mrproper --no-zfs --no-lvm --no-mdadm --no-dmraid --no-multipath --no-iscsi --no-luks --no-gpg --no-unionfs --no-firmware
 emerge -1qv @module-rebuild
fi
if [ $script = "gtc-buildkernel-menuconfig" ]
then
 emerge -1qv @module-rebuild
fi

# Get Kernels Version number
KERNEL=`ls -ld  /usr/src/linux | cut -d">" -f2 | sed 's/^ linux-//'`

### edit genkernel initrd ###
if [ -d /tmp/initrd ]
then
 rm -rf /tmp/initrd
fi
if [ -f /tmp/initrd ]
then 
 rm -f /tmp/initrd
fi
mkdir /tmp/initrd
cd /tmp/initrd

# extract initrd
cp /boot/initramfs-genkernel-x86-$KERNEL /boot/initramfs-genkernel-x86-$KERNEL.original
#gzip -dc /boot/initramfs-genkernel-x86-$KERNEL | cpio -id
xzcat /boot/initramfs-genkernel-x86-$KERNEL.original | cpio -dim


# Copy network modules to initrd
mkdir -p /tmp/initrd/lib/modules/$KERNEL/kernel/drivers/net
rsync -a --exclude=hamachi.ko --exclude=wireless --exclude=irda --exclude=phy --exclude=wan --exclude=bonding /lib/modules/$KERNEL/kernel/drivers/net/ /tmp/initrd/lib/modules/$KERNEL/kernel/drivers/net/
cp -p /lib/modules/$KERNEL/modules.order /tmp/initrd/lib/modules/$KERNEL/modules.order
cp -p /lib/modules/$KERNEL/modules.builtin /tmp/initrd/lib/modules/$KERNEL/modules.builtin
mkdir -p /tmp/initrd/lib/modules/$KERNEL/kernel/net
rsync -a --exclude=netfilter --exclude=wireless --exclude=bluetooth /lib/modules/$KERNEL/kernel/net/ /tmp/initrd/lib/modules/$KERNEL/kernel/net
mkdir -p /tmp/initrd/lib/modules/$KERNEL/kernel/lib
rsync -a /lib/modules/$KERNEL/kernel/lib/ /tmp/initrd/lib/modules/$KERNEL/kernel/lib

# Copy nfs modules
mkdir -p /tmp/initrd/lib/modules/$KERNEL/kernel/fs/nfs
cp -rp /lib/modules/$KERNEL/kernel/fs/nfs/* /tmp/initrd/lib/modules/$KERNEL/kernel/fs/nfs/
mkdir -p /tmp/initrd/lib/modules/$KERNEL/kernel/fs/nfs_common
cp -rp /lib/modules/$KERNEL/kernel/fs/nfs_common/* /tmp/initrd/lib/modules/$KERNEL/kernel/fs/nfs_common/

brctl=`which brctl`
cp $brctl /tmp/initrd/bin
for i in `for i in \`ldd $brctl | grep lib/\` ; do echo $i; done | grep lib/`
do 
 cp $i /tmp/initrd/lib
done

nfsmount=`which mount.nfs`
cp $nfsmount /tmp/initrd/bin
for i in `for i in \`ldd $nfsmount | grep lib/\` ; do echo $i; done | grep lib/`
do
 cp $i /tmp/initrd/lib
done

rpcbind=`which rpcbind`
cp $rpcbind /tmp/initrd/bin
for i in `for i in \`ldd $rpcbind | grep lib/\` ; do echo $i; done | grep lib/`
do
 cp $i /tmp/initrd/lib
done
cp /etc/netconfig /tmp/initrd/etc/
cp /etc/services /tmp/initrd/etc/
cp /etc/rpc /tmp/initrd/etc/
cp /etc/protocols /tmp/initrd/etc/

idmapd=`which rpc.idmapd`
cp $idmapd /tmp/initrd/bin
for i in `for i in \`ldd $idmapd | grep lib/\` ; do echo $i; done | grep lib/`
do
 cp $i /tmp/initrd/lib
done
cp /lib/libnss* /tmp/initrd/lib/
cp -r /usr/lib/libnfsidmap* /tmp/initrd/lib/
mkdir -p /tmp/initrd/var/lib/nfs/rpc_pipefs/nfs
cp -P /etc/localtime /tmp/initrd/etc/
cp /etc/passwd /tmp/initrd/etc/
cp /etc/group /tmp/initrd/etc/
cp /etc/nsswitch.conf /tmp/initrd/etc/
cp /etc/idmapd.conf /tmp/initrd/etc/

rsync=`which rsync`
cp $rsync /tmp/initrd/bin
for i in `for i in \`ldd $rsync | grep lib/\` ; do echo $i; done | grep lib/`
do
 cp $i /tmp/initrd/lib
done

strace=`which strace`
cp $strace /tmp/initrd/bin
for i in `for i in \`ldd $strace | grep lib/\` ; do echo $i; done | grep lib/`
do
 cp $i /tmp/initrd/lib
done

depmod -a -b /tmp/initrd $KERNEL
# Copy firmware to initrd
#rsync -a --exclude=radeon /lib/firmware /tmp/initrd/lib/
mkdir -p /tmp/initrd/lib/firmware
cd /lib/firmware
cp -r 3com bnx2* tigon /tmp/initrd/lib/firmware
cd -

# Edit file for loading Network modules
mkdir -p /tmp/initrd/etc/modules
>/tmp/initrd/etc/modules/net
>/tmp/initrd/etc/modules/gtcnet
for i in `find /tmp/initrd/lib/modules/$KERNEL/kernel/drivers/net/ -type f -name *.ko | sort`; 
do 
 mod="`basename $i | sed 's/\.ko$//'`"
 echo "$mod" >> /tmp/initrd/etc/modules/gtcnet
done
echo "bridge" >> /tmp/initrd/etc/modules/gtcnet

# Create new NFS/Networking script for initrd
echo '
gtcdebug() {
 if cat /proc/cmdline | grep -i gtcdebug >/dev/null
  then
  set -x
 fi
}
' >/tmp/initrd/etc/gtc

echo '
gtcnet() {
 if [ $BOOTIF = "00-00-00-00-00-00" ]
 then
  good_msg "Not doing any network configuration"
 else
  good_msg "Loading network modules"
  modules_scan gtcnet
  if [ "${IP}" = "" ]
  then
   good_msg "No IP-Parameter... Trying DHCP..."
   if busybox udhcpc -n -T 15 -q
   then
    good_msg "Got IP via DHCP"
    if=`ifconfig | grep eth | head -n1 | cut -d" " -f1`
    mac=`ifconfig $if | head -n1 | sed "s/ */ /g" | cut -d" " -f6`
    ip=`ifconfig $if | head -n2 | tail -n1 | sed "s/ */ /g" | cut -d" " -f3 | sed "s/^addr://g"`
    nm=`ifconfig $if | head -n2 | tail -n1 | sed "s/ */ /g" | cut -d" " -f5 | sed "s/^Mask://g"`
    gw=`route -n | grep "^0.0.0.0" | sed "s/ */ /g" | cut -d" " -f3`
   else
    bad_msg "Got no network configuration - No DHCP and no Kernel IP parameter"
    if=""
   fi
   nonetboot=1
  else
   mac=`echo $BOOTIF | sed s/-/:/g | sed s/^..://`
   ip=`echo $IP | cut -d: -f1`
   gw=`echo $IP | cut -d: -f3`
   nm=`echo $IP | cut -d: -f4`
   if=`ifconfig -a | grep -i $mac | head -n1 | cut -d" " -f1`
   nonetboot=""
  fi
  if [ -n "$if" ]
  then
   good_msg "Setting up Networking for Interface $if - $mac"
   good_msg "Creating Bridge br0 for $if"
   brctl addbr br0 || /bin/sh
   brctl setfd br0 0 || /bin/sh
   brctl addif br0 $if || /bin/sh
   ifconfig $if 0.0.0.0 promisc up || /bin/sh
   good_msg "Setting IP and Netmask $ip/$nm"
   ifconfig br0 $ip netmask $nm || /bin/sh
   good_msg  "Setting default Gateway $gw"
   route add default gw $gw br0  || /bin/sh
  fi
 fi
}
' >>/tmp/initrd/etc/gtc

echo '
gtccreaterw() {

 good_msg "Mounting Ramdisk with tmpfs"
 nr=${NEW_ROOT}
 mount -n -t tmpfs -o size=256M tmpfs $nr || /bin/sh
 
 good_msg "Mounting Root"
 mkdir -p $nr/_gtcroot
 
 # GTC DVD
 if cat /proc/cmdline | grep gtcdvd >/dev/null
 then
  good_msg "Searching for the DVD"
  mkdir -p $nr/_gtcdvdroot
  for dev in `find /dev -maxdepth 1 -name "*[s|h|xv]d?" -type b ; find /dev -maxdepth 1 -name "*sr?" -type b`
  do
   mount -n -t iso9660 $dev $nr/_gtcdvdroot >/dev/null 2>&1
   if [ -f "$nr/_gtcdvdroot/gtc" ]
   then
    dvdfound=$dev
   else
    umount -lf $dev >/dev/null 2>&1
   fi
  done
  if [ -z $dvdfound ]
  then
   bad_msg "No GTC-DVD found"
   /bin/sh
  fi
  good_msg "DVD-Device is $dvdfound"
  good_msg "Mounting GTC-Image"
  if mount -n -t squashfs -o loop,ro $nr/_gtcdvdroot/gtc $nr/_gtcroot
  then
   good_msg "GTC-Image mounted"
  else
   bad_msg "Could not mount $nr/_gtcdvdroot/gtc"
   /bin/sh
  fi

 # GTC HDD
 elif cat /proc/cmdline | grep gtchdd >/dev/null
 then
  good_msg "Searching for the GTC-HDD"
  for arg in `cat /proc/cmdline`
  do
   if echo "$arg" | grep -i "root=UUID" >/dev/null
   then
    uuid=`echo $arg | cut -d"=" -f3`
    hdd=`blkid | grep $uuid | cut -d: -f1` 
   fi
  done
  good_msg "GTC-HDD $hdd with UUID $uuid found - Trying to mount"
  if mount $hdd $nr/_gtcroot
  then
   good_msg "GTC-HDD mounted"
  else
   bad_msg "Could not mount $uuid"
   /bin/sh
  fi

 # GTC NFS
 else
  good_msg "Mounting NFS-Root ${NFSROOT}"
  /sbin/modprobe nfs >/dev/null
  /sbin/modprobe nfsv3 >/dev/null
  mkdir -p /var/run
  if [ -f /bin/portmap ]
  then
   /bin/portmap || /bin/sh
  else
   /bin/rpcbind || /bin/sh
  fi
  mkdir -p /var/lib/nfs/rpc_pipefs
  mount -t rpc_pipefs none /var/lib/nfs/rpc_pipefs
  mkdir -p $nr/var/lib/nfs/rpc_pipefs
  mount -n -t rpc_pipefs none $nr/var/lib/nfs/rpc_pipefs
  #/bin/rpc.idmapd || /bin/sh
  ln -s /bin/mount.nfs /bin/mount.nfs4
  mount.nfs $NFSROOT $nr/_gtcroot -o suid,ro,async,hard,intr,nolock,nfsvers=3 || /bin/sh
 fi

 good_msg "Creating RW-Directory-Structure for /etc, /var, /tmp and /dev"
 cd $nr
 mkdir -p $nr/home $nr/sys $nr/proc $nr/root $nr/media $nr/mnt $nr/etc/gconf $nr/var/tmp $nr/var/lib/texmf $nr/tmp $nr/run
 rsync -a --exclude=thinclient/profiles/ --exclude=gconf/ $nr/_gtcroot/etc $nr/ || /bin/sh
 rsync -a --exclude=lib/texmf/ --exclude=/www/ --exclude=cache/edb/ --exclude=db/pkg/ --exclude=tmp/ $nr/_gtcroot/var $nr/ || /bin/sh
 rsync -a $nr/_gtcroot/dev $nr/ || /bin/sh
 chmod 1777 $nr/var/tmp
 chmod 1777 $nr/tmp
 chmod 0700 $nr/root
 
 # Copy thinclien.conf from DVD if exists
 if [ -f $nr/_gtcdvdroot/conf ]
 then
  good_msg "Using thinclient.conf.local (conf) from DVD"
  cp $nr/_gtcdvdroot/conf $nr/etc/thinclient.conf.local
 fi

 good_msg "Bind Mounting RO-Directory-Structure"
 for i in `ls $nr/_gtcroot | grep -v etc | grep -v home | grep -v var | grep -v tmp | grep -v sys | grep -v proc | grep -v run | grep -v root | grep -v lost+found | grep -v media | grep -v cdrom | grep -v floppy | grep -v mnt | grep -v dev` etc/gconf var/lib/texmf
 do
  if [ -d $nr/_gtcroot/$i ]
  then
   good_msg "Bind-Mounting $i"
   mkdir -p $nr/$i
   mount -n --bind $nr/_gtcroot/$i $nr/$i
  fi
 done

 good_msg "Copy possible existing Links in /"
 cd $nr/_gtcroot
 find . -maxdepth 1 -type l -exec cp -P {} $nr/ \;
 
 good_msg "Writing mtab"
 cat /proc/mounts | sed s/newroot\\/// | sed s/\\/newroot/\\// | grep -v rootfs | grep -v rpc_pipefs | grep -v /usr | grep -v /sbin | grep -v /lib | grep -v /bin > $nr/etc/mtab
 
 good_msg "Removing 70-persistent-net.rules"
 rm -f $nr/etc/udev/rules.d/70-persistent-net.rules

 good_msg "Creating /etc/thinclient/bootif"
 echo "$if" > $nr/etc/thinclient/bootif

 if [ -z $nonetboot ]
 then
  good_msg "Setting up DNS from thinclient.conf"
  good_msg "Getting Nameserver configuration"
  source $nr/etc/thinclient/thinclient.conf
  if [ -f $nr/etc/thinclient/thinclient.conf.local ]
  then
   source $nr/etc/thinclient/thinclient.conf.local
  fi
  if [ -n "$NAMESERVERBACKUP" ]
  then
   BACKUP="
nameserver $NAMESERVERBACKUP
options timeout:2"
  fi
  good_msg "Setting up nameserver $NAMESERVER and search suffix $SEARCH"
  echo "nameserver $NAMESERVER$BACKUP
search $SEARCH" > /etc/resolv.conf
 fi
 touch /etc/resolv.conf
 cp /etc/resolv.conf $nr/etc/resolv.conf
}
' >>/tmp/initrd/etc/gtc

echo '
gtcshell() {
 if cat /proc/cmdline | grep -i gtcshell >/dev/null
 then
  /bin/sh
 fi
}
' >>/tmp/initrd/etc/gtc

echo '
gtcprofile() {
 if cat /proc/cmdline | grep -i "gtcprofile=" >/dev/null
 then
  for arg in `cat /proc/cmdline`
  do
   if echo "$arg" | grep -i "gtcprofile=" >/dev/null
   then
    NAME=`echo $arg | cut -d"=" -f2`
   fi
  done
 else
  good_msg "Trying to get and set hostname/profile over reverse DNS for $ip"
  chroot $nr /usr/bin/host $ip >/dev/null 2>/dev/null
  if [ $? == "0" ]
  then
   NAME=$(chroot $nr /usr/bin/host $ip | cut -d " " -f 5 | sed -e s/\.$//)
   good_msg "Adding to $nr/etc/hosts -> $ip $NAME"
   echo "$ip $NAME" >> $nr/etc/hosts
  else
   NAME="gtc-default"
  fi
 fi
 good_msg "Setting hostname to $NAME"
 if [ -d "$nr/_gtcroot/etc/thinclient/profiles/$NAME" ]
 then
  good_msg "Copying profile for $NAME"
  mkdir -p $nr/etc/thinclient/profiles/$NAME || /bin/sh
  rsync -a --exclude=software $nr/_gtcroot/etc/thinclient/profiles/$NAME/ $nr/etc/thinclient/profiles/$NAME/ || /bin/sh
 else
  good_msg "No profile for $NAME"
 fi
 mv $nr/etc/conf.d/hostname $nr/tmp/
 sed -e s/^hostname.*/hostname\=\"$NAME\"/ $nr/tmp/hostname > $nr/etc/conf.d/hostname
}
' >>/tmp/initrd/etc/gtc

echo '
findnfsmount() {
 source /etc/gtc
 gtcdebug
 gtcnet
 gtccreaterw
 gtcprofile
 gtcshell
}
rundebugshell() {
 echo x >/dev/null 2>&1
}

' >> /tmp/initrd/etc/initrd.scripts

# Create new initrd
cd /tmp/initrd
#find ./ | cpio -H newc -o > /boot/initramfs-genkernel-x86-$KERNEL
find ./ | cpio -o -H newc | xz --format=lzma > /boot/initramfs-genkernel-x86-$KERNEL
rm -f /boot/initrd
#gzip /boot/initramfs-genkernel-x86-$KERNEL
#mv /boot/initramfs-genkernel-x86-$KERNEL.gz /boot/initramfs-genkernel-x86-$KERNEL

# link it 
rm -f /boot/kernel
ln /boot/kernel-genkernel-x86-$KERNEL /boot/kernel
ln /boot/initramfs-genkernel-x86-$KERNEL /boot/initrd

# Generate modules.dep
depmod -a $KERNEL


Changes in /gtc/test/etc/thinclient/scripts/gtc-ieurl

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-ieurl

Changed on 21.11.09
Issued by olli
Beginning line 2

Script for starting Firefox with URLs/Links/Bookmarks/Favorites from the Internet Explorer (*.url-files)

#!/bin/bash
firefox `cat "$1" | grep "^URL" | cut -d"=" -f2`

Changes in /gtc/test/etc/thinclient/scripts/gtc-info

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-info

Changed on 02.12.10
Issued by olli
Beginning line 2

Script for collecting systeminformations. This maybe for supportmails.

#!/bin/bash
#
# Script for getting system informations:

echo '
set -x

# boot and hardware
cat /proc/cmdline
cat /proc/cpuinfo
dmesg
free -m
lspci
lsusb

# network
ifconfig -a
route -n
brctl show
brctl show | while read bridge
do 
 br=`echo $bridge | grep "8000\." | cut -d" " -f1`
 if [ -n "$br" ]
 then 
  brctl showstp $br
 fi
done

# tasks and user
who
ps aux

# time
ls -ld /etc/localtime
date

# hdds
mount
df -h
cat /proc/mounts

# logs
find /var/log -type f | grep -v emerge.log | while read log
do
 if file $log | grep text
 then
  ls -l $log
  cat $log
 fi
done

# configs
find /etc -type f | while read conf
do
 if file -b $conf | grep text
  then
  ls -l $conf
  cat $conf
 fi
done

' >/tmp/gtc-info
date=`date +%Y-%m-%d-%H-%M-%S`
sh /tmp/gtc-info > ~/gtc-info-$date-$$.log 2>&1

echo "Informations are in /root/gtc-info-*"

echo -n  "Please enter an eMail-Address to send the info: "
read mail
cat ~/gtc-info-$date-$$.log | mail -s "GTC-Info `hostname` $date-$$" $mail


Changes in /gtc/test/etc/thinclient/scripts/gtc-install

File permissions:
Owner: root
Group: root
Permissions: -rwx------

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-install

Changed on 08.11.10
Issued by olli
Beginning line 2

Userinteractive Installationscript for the GTC on a disk.

#!/bin/bash
echo "Welcome to the GTC installer!"

# Choosing a Disk
echo "
This will guide you through the installation on a local disk or USB device."
if blkid | grep 'LABEL="GTC"' >/dev/null
then
 if blkid | grep 'LABEL="GTCDATA"' >/dev/null
 then 
  if blkid | grep 'LABEL="GTCSWAP"' >/dev/null
  then
   gtcdisk=`blkid | grep 'LABEL="GTC"' | tail -n1 | cut -d ":" -f1` 
   gtcdata=`blkid | grep 'LABEL="GTCDATA"' | tail -n1 | cut -d ":" -f1`
   gtcswap=`blkid | grep 'LABEL="GTCSWAP"' | tail -n1 | cut -d ":" -f1`
   dev=`echo $gtcdisk | sed 's/[0-9]//g'`
   echo "Found Partition-Labels for the GTC-Partitions:
GTC-Systemdisk is $gtcdisk
GTC-Datadisk is $gtcdata
GTC-Swapdisk is $gtcswap
Shall we install/update on this partitions and overwrite the bootsector (MBR) on $dev? If yes please enter \"yes\""
   read partitions
  fi 
 fi
fi

if [ "$partitions" = "yes" ]
then
 umount -lf $gtcdata
 umount -lf $gtcdisk
 echo "Disks selected."
else
 echo "Here is a list of devices the GTC can be installed:
"
 fdisk -l | grep " /dev/" | grep -v "t contain"
 echo "
WARNING: ALL DATA ON THE DISK YOU CHOOSE WILL BE DELETED!!!!
Please enter the devicname name e.g. /dev/sdb you want to install the GTC."
 echo "Device: "
 read dev
 dev=`echo $dev | sed 's/^\/dev\///'`
 dev="/dev/$dev"
 if cat /proc/mounts | grep $dev
 then
  echo "
$dev is already mounted - Cannot install on a mounted disk"
  exit 1
 fi

 if [ -b "$dev" ] 
 then
  echo "WARNING: ALL DATA ON $dev WILL BE DELETED!!!!"
  echo "If you are absolutely sure you want to delete all data in $dev and install the GTC in it enter \"yes\": "
  read sure
  if [ "$sure" = "yes" ]
  then
   echo "OK, so let's install GTC on $dev!"
  else
   echo "Installation canceld!"
   exit 1
  fi
 else
  echo "$dev does not exist or is not a valid block device!"
  exit 1
 fi
fi

for i in `cat /proc/mounts | grep $dev | cut -d" " -f1` 
do
 echo "
 $i is already mounted - Umounting..."
 umount -lf $i
done


# Choosing the systems role
echo "

What system role do you want to install?

- Server (A Server for the Gentoo ThinClients)
- Live (A Livesystem e.g.: for testing the GTC)
- Profile (A System with a specified profile)

Please enter Server, Profile or Live: "
read role
if echo "$role" | grep -i "^s"
then
 inst="gtc-srvinst"
elif echo "$role" | grep -i "^p"
then
 inst="gtc-profileinst"
elif  echo "$role" | grep -i "^l"
then
 inst="gtc-liveinst"
else
 echo "No valid role entered!"
 exit 1
fi
inst="/etc/thinclient/scripts/$inst"

if [ "$partitions" = "yes" ]
then
 $inst $gtcdisk $dev
else
 # Create a partition and a filesystem
 echo "Preparing $dev"
 echo "Creating partitions on $dev"
 sfdisk $dev <<__EOF__
2048,61140000,L
,2480000,S
,,L
__EOF__
 sleep 10
 echo "Formating partitions on $dev"
 mkfs.ext3 -m1 -L "GTC" ${dev}1 || exit 1
 mkswap ${dev}2 -L "GTCSWAP" || exit 1
 mkfs.ext3 -m1 -L "GTCDATA" ${dev}3 || exit 1
 
 # Start installation
 echo "Starting the installation"
 $inst ${dev}1 $dev
fi

Changes in /gtc/test/etc/thinclient/scripts/gtc-instupdate

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-instupdate

Changed on 08.11.09
Issued by olli
Beginning line 2

GTC-Systemupdate script

#!/bin/bash
if mount | grep "/_gtcroot type nfs"
then
 echo "No update on an NFS-Client possible!"
 exit 1
fi

touch /_gtcroot/wtest || exit 1
rm /_gtcroot/wtest

mkdir -p /_gtcroot/_tmpupdate
echo ">>> Downloading files"

until rsync -avXAH --progress --timeout=300 --delete-before --exclude=/update.log --exclude=/_additionalsw --exclude=/tmp --exclude=/sys --exclude=/root --exclude=/srv --exclude=/home --exclude=/gtcdvd --exclude=/gtcdvd.iso --exclude=/_gtcroot --exclude=/_additionalsw --exclude=/etc/shadow --exclude=/etc/thinclient/*profile --exclude=/etc/thinclient/profiles --exclude=/boot/grub --exclude=/boot/grub2--exclude=/etc/fstab --exclude=/var/lib/samba/private/secrets.tdb --exclude=/_tmpupdate --link-dest=/_gtcroot/ --numeric-ids rsync://gtc.example.com/thinclient/ /_gtcroot/_tmpupdate/
do
 sync
 echo "!!! ERROR downloading Update - Retrying"
done

sync
echo ">>> Download successfully finished"
>/_gtc-update/update-down

echo ">>> Updating files - DO NOT TURN OFF YOUR COMPUTER!!!"
if rsync -aXAH --progress --delete-before --exclude=/tmp --exclude=/sys --exclude=/root --exclude=/srv --exclude=/home --exclude=/gtcdvd --exclude=/gtcdvd.iso --exclude=/_gtcroot --exclude=/_additionalsw --exclude=/etc/shadow --exclude=/etc/thinclient/*profile --exclude=/etc/thinclient/profiles --exclude=/boot/grub --exclude=/boot/grub2 --exclude=/etc/fstab --exclude=/var/lib/samba/private/secrets.tdb --exclude=/_tmpupdate --numeric-ids /_gtcroot/_tmpupdate/  /_gtcroot/
then
 sync
 echo ">>> Update successfully finished"
else
 sync
 echo "!!! Update ERROR"
 exit 1
fi

echo ">>> Renewing additional Software"
cp /etc/resolv.conf /_gtc-update/etc/

cp -p /etc/resolv.conf /_gtcroot/etc/
mkdir -p /_gtcroot/proc
chroot /_gtcroot /bin/bash -c "env-update &>/dev/null && source /etc/profile && mount -t proc proc /proc; gtc-additional-sw-del ; gtc-additional-sw-add"
umount -lf /_gtcroot/proc
sync

echo "

Update is finished!!! Please reboot your system...
"



Changes in /gtc/test/etc/thinclient/scripts/gtc-mkiso

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-mkiso

Changed on 08.11.09
Issued by olli
Beginning line 2

Script for creating the GTC DVD-Image

#!/bin/bash
rm -rf /gtcdvd
mkdir -p /gtcdvd/boot
KERN=`basename \`ls -tr1 /boot/kernel-genkernel-* | tail -n1\``
INITRD=`basename \`ls -tr1 /boot/initramfs-genkernel-* | tail -n1\``
cp /boot/$KERN /gtcdvd/boot/kernel
cp /boot/$INITRD /gtcdvd/boot/initrd
cp /usr/share/syslinux/isolinux.bin /gtcdvd/
cp /usr/share/syslinux/menu.c32 /gtcdvd/

version=`head /etc/thinclient/gtc-release-notes -n1 | cut -d" " -f2`

echo "default menu.c32
prompt 0
menu title GTC LiveDVD $version
ALLOWOPTIONS 1
MENU AUTOBOOT Starting GTC DVD in # seconds

label GTC-$KERN
 menu label ^GTC - Livesystem - $version
 timeout 150
 kernel /boot/kernel
 append initrd=/boot/initrd ramdisk_size=256000 acpi_sleep=s3_bios real_root=/dev/nfs gtcdvd dokeymap i915.modeset=1 radeon.modeset=1

label GTC-$KERN
 menu label ^GTC - Server with XXX.XXX.XXX.XXX/24 - $version
 kernel /boot/kernel
 append initrd=/boot/initrd ramdisk_size=256000 acpi_sleep=s3_bios real_root=/dev/nfs gtcdvd gtcserver i915.modeset=1 radeon.modeset=1 dokeymap ip=XXX.XXX.XXX.XXX:XXX.XXX.XXX.XXX:XXX.XXX.XXX.XXX:XXX.XXX.XXX.XXX BOOTIF=eth


label GTC-$KERN
 menu label ^GTC - Installation - $version
 kernel /boot/kernel
 append initrd=/boot/initrd ramdisk_size=256000 acpi_sleep=s3_bios real_root=/dev/nfs gtcdvd gtcinstall dokeymap i915.modeset=1 radeon.modeset=1
" > /gtcdvd/isolinux.cfg

if [ -d "/_gtcroot" ]
then
 echo "Using /_gtcroot"
else
 mkdir -p /_gtcroot 
 mount --bind / /_gtcroot
fi
cp /etc/thinclient/gtc-release-notes /gtcdvd/`date +%Y%m%d`
mksquashfs /_gtcroot/ /gtcdvd/gtc -e gtcdvd.iso -e gtcdvd -e _gtcroot -e etc/thinclient/profiles -e _additionalsw -e usr/portage/distfiles -e usr/src -e etc/thinclient/thinclient.conf.local
umount /_gtcroot 2>/dev/null ; rmdir /_gtcroot 2>/dev/null

mkisofs -R -V "GTC DVD" -o /gtcdvd.iso -b isolinux.bin -c boot.catalog -no-emul-boot -boot-load-size 4 -boot-info-table /gtcdvd/

Changes in /gtc/test/etc/thinclient/scripts/gtc-update

File permissions:
Owner: root
Group: root
Permissions: -rwx------

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-update

Changed on 08.12.09
Issued by olli
Beginning line 2

GTC-Systemupdate Update script

#!/bin/bash

if mount | grep "/_gtcroot type nfs"
then
 echo "No update on an NFS-Client possible!"
 exit 1
fi

. /etc/thinclient/scripts/gtc-confs.sh
if [ "$UPDATECHANNEL" = "test" ]
then
 chan="-test"
 echo "WARNING: Using Test-Channel"
fi

until rsync -aH --timeout=300 rsync://gtc.example.com/thinclient$chan/etc/thinclient/scripts/ /etc/thinclient/scripts/
do
 sync
 echo "!!! ERROR downloading System-Update Update - Retrying"
done

rsync -aH /etc/thinclient/scripts/ /_gtcroot/etc/thinclient/scripts/
rsync -aH --delete --timeout=300 rsync://gtc.example.com/thinclient$chan/etc/thinclient/login/ /_gtcroot/etc/thinclient/login/
rsync -aH --timeout=300 rsync://gtc.example.com/thinclient$chan/etc/thinclient/startup/ /_gtcroot/etc/thinclient/startup/
rsync -aH --timeout=300 rsync://gtc.example.com/thinclient$chan/etc/local.d/ /_gtcroot/etc/local.d/
rsync -aH /_gtcroot/etc/local.d/ /etc/local.d/

until rsync -aH --timeout=300 rsync://gtc.example.com/thinclient$chan/etc/thinclient/gtc-release-notes /etc/thinclient/gtc-release-notes-new
do
 echo "!!! ERROR downloading GTC Release-Information - Retrying"
 sleep 30
done
if [ "`cat /_gtcroot/etc/thinclient/gtc-release-notes | head -n1`" = "`cat /etc/thinclient/gtc-release-notes-new | head -n1`" ]
then
 echo "No Update from `cat /etc/thinclient/gtc-release-notes | head -n1` available"
 exit 0
else
 echo "Updateing from `cat /etc/thinclient/gtc-release-notes | head -n1` to `cat /etc/thinclient/gtc-release-notes-new | head -n1`"
fi

sync
echo ">>> System-Update Update successfully finished"

sh /etc/thinclient/scripts/gtc-update-fetch


Changes in /gtc/test/etc/thinclient/scripts/gtc-update-do

File permissions:
Owner: root
Group: root
Permissions: -rwx------

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-update-do

Changed on 02.01.12
Issued by olli
Beginning line 2

GTC-Systemupdate Update script

#!/bin/bash

if mount | grep "/_gtcroot type nfs"
then
 echo "No update on an NFS-Client possible!"
 exit 1
fi

if [ -f /_gtcroot/update-down ]
then
 echo "There is a new systm update available and already downloaded - Please enter \"yes\" to install it: "
 read sure
 if [ "$sure" = "yes" ]
 then
  echo ">>> Updating files 
DO NOT TURN OFF YOUR COMPUTER!!! THIS MAY TAKE A VERY LONG TIME!!!
NICHT DEN COMPUTER AUSSCHALTEN!!! DER VORGANG KANN SEHR LANGE DAUERN!!!"
 else
  exit 0
 fi
else
 exit 0
fi

rm -f /_gtcroot/update-down /_gtcroot/_tmpupdate/update-down

if rsync -aXAHq  --delete-before --exclude=/tmp --exclude=/sys --exclude=/root --exclude=/srv --exclude=/home --exclude=/gtcdvd --exclude=/gtcdvd.iso --exclude=/_gtcroot --exclude=/_additionalsw --exclude=/etc/shadow --exclude=/etc/thinclient/*profile --exclude=/etc/thinclient/profiles --exclude=/boot/grub --exclude=/boot/grub2 --exclude=/etc/fstab --exclude=/var/lib/samba/private/secrets.tdb --exclude=/_tmpupdate --link-dest=/_gtcroot/_tmpupdate/ --numeric-ids /_gtcroot/_tmpupdate/  /_gtcroot/
then
 sync
 echo ">>> Update successfully finished"
else
 sync
 echo "!!! Update ERROR"
 exit 1
fi

rm -f /_gtcroot/update-down /_gtcroot/_tmpupdate/update-down

/etc/thinclient/scripts/gtc-update-post


Changes in /gtc/test/etc/thinclient/scripts/gtc-update-fetch

File permissions:
Owner: root
Group: root
Permissions: -rwx------

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-update-fetch

Changed on 08.11.09
Issued by olli
Beginning line 2

GTC-Systemupdate script

#!/bin/bash
if mount | grep "/_gtcroot type nfs"
then
 echo "No update on an NFS-Client possible!"
 exit 1
fi

. /etc/thinclient/scripts/gtc-confs.sh
if [ "$UPDATECHANNEL" = "test" ]
then
 chan="-test"
fi

touch /_gtcroot/wtest || exit 1
rm /_gtcroot/wtest

if [ -f "/_gtcroot/update-down" ]
then
 /etc/thinclient/scripts/gtc-update-do
else
 mkdir -p /_gtcroot/_tmpupdate
 echo ">>> Downloading files"
 until rsync -aH --progress --timeout=300 --delete --exclude=/update.log --exclude=/_additionalsw --exclude=/tmp --exclude=/sys --exclude=/root --exclude=/srv --exclude=/home --exclude=/gtcdvd --exclude=/gtcdvd.iso --exclude=/_gtcroot --exclude=/_additionalsw --exclude=/etc/thinclient/profiles --exclude=/boot/grub --exclude=/boot/grub2 --exclude=/etc/fstab --exclude=/var/lib/samba/private/secrets.tdb --exclude=/_tmpupdate --link-dest=/_gtcroot/ --numeric-ids rsync://gtc.example.com/thinclient$chan/ /_gtcroot/_tmpupdate/
 do
  sync
 done
 sync 
 >/_gtcroot/update-down
fi

if [ -f "/_gtcroot/update-down" ]
then
 /etc/thinclient/scripts/gtc-update-do
fi


Changes in /gtc/test/etc/thinclient/scripts/gtc-update-post

File permissions:
Owner: root
Group: root
Permissions: -rwx------

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-update-post

Changed on 02.01.12
Issued by olli
Beginning line 2

GTC-Systemupdate Update script

#!/bin/bash

if mount | grep "/_gtcroot type nfs"
then
 echo "No update on an NFS-Client possible!"
 exit 1
fi
  
echo ">>> Renewing additional Software"
cp /etc/resolv.conf /_gtcroot/etc/

cp -p /etc/resolv.conf /_gtcroot/etc/
mkdir -p /_gtcroot/proc
chroot /_gtcroot /bin/bash -c "env-update &>/dev/null && source /etc/profile && mount -t proc proc /proc; gtc-additional-sw-del ; gtc-additional-sw-add"
umount -lf /_gtcroot/proc
sync

echo "

Update is finished!!! System will reboot now...

"

sleep 10
reboot


Changes in /gtc/test/etc/thinclient/startup/gtc-startupconfig

File permissions:
Owner: root
Group: root
Permissions: -r-x------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/gtc-startupconfig

Changed on 27.10.09
Issued by olli
Beginning line 10

This runs all the scripts for configuring global and individualsettings for all thinclients..


# Routing
echo 1 > /proc/sys/net/ipv4/ip_forward

# Console blanking abstellen
setterm -blank 0

# VirtualBox
modprobe vboxdrv >/dev/null 2>&1
modprobe vboxnetadp >/dev/null 2>&1
modprobe vboxnetflt >/dev/null 2>&1
modprobe vboxpci >/dev/null 2>&1
if ifconfig | grep br0 >/dev/null 2>&1
then
 echo "OK" >/dev/null
else
 brctl addbr br0 >/dev/null 2>&1
 ifconfig br0 up >/dev/null 2>&1
fi

# clean sudo-io
rm -rf /var/log/sudo-io/*

# reset AccountsService
rm -f /var/lib/AccountsService/users/*

# Get /dev/dsp i.e. for old games
modprobe snd-pcm-oss 2>/dev/null

# Trying to mount GTCDATA and GTCSWAP-Partitions
mkdir -p /srv
mount LABEL=GTCDATA /srv >/dev/null 2>&1 || rmdir /srv
swapon LABEL=GTCSWAP >/dev/null 2>&1
# Delete Cache+Thumbnail-Dirs in /home-dirs
rm -rf /srv/share/home/*/.cache
rm -rf /srv/share/home/*/.thumbnails
if [ -d /srv/config ]
then
 rsync -a --exclude=thinclient.conf.local --exclude=profiles --exclude=global-profile --delete /etc/thinclient/ /srv/config/
 mount -B /srv/config /etc/thinclient
fi
if [ -d /srv/profiles ]
then
 mount -B /srv/profiles /etc/thinclient/profiles
fi
if [ -d /srv/global-profile ]
then
 mount -B /srv/global-profile /etc/thinclient/global-profile
fi

echo "127.0.0.1 `hostname`" >>/etc/hosts
. /etc/thinclient/scripts/gtc-confs.sh

# Create smb.conf (is needed for cups in some cases)
touch /etc/samba/smb.conf

# Check for enabled Debug-Mode
if [ $DEBUG == "yes" ]
then
 set -x
 RSYNC_OPT="v"
fi

# Disable Network and loop Umounts during shutdown
echo '
stop()
{
 return 0
}
' >> /etc/init.d/localmount
echo '
stop()
{
 return 0
}
' >> /etc/init.d/netmount

# Make wheel group admin (duso)
echo '%wheel	ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# If this is a local GTC
if mount | grep "/_gtcroot type nfs" >/dev/null
then
 echo "This GTC networt booted"
else
 # Restore mixer settings
 if [ -f /etc/thinclient/profiles/`hostname`/local/mixersettings ]
 then
  echo "Restoring Mixer settings"
  alsactl restore -f /etc/thinclient/profiles/`hostname`/local/mixersettings
 fi
 # Set local home's
 mount --bind /_gtcroot/root /root
 mkdir -p /srv/home /home
 mount --bind /srv/home /home
 # Create local user
 if [ -z "$LOCALUSER" ]
 then
  echo "Creating no local User"
 else
  for LU in $LOCALUSER
  do
   echo "Creating local user $LU"
   cp -p /etc/shadow /etc/shadow.bak
   useradd -g users -G wheel,root,audio,video,cdrom,vboxusers,cdrw,usb,games,disk,lpadmin,lp,scanner,sys,adm,floppy -d /home/$LU $LU
   if grep -a "^$LU" /etc/thinclient/profiles/`hostname`/local/shadow >/dev/null 2>&1
   then
    grep -a "^$LU" /etc/thinclient/profiles/`hostname`/local/shadow > /etc/shadow2
    cat -vT /etc/shadow | grep -a -v "^$LU" >> /etc/shadow2
    mv /etc/shadow2 /etc/shadow
    chmod 0600 /etc/shadow
   else
    echo $LU:gtc | chpasswd
   fi
   if [ -d /home/$LU ]
   then
    echo "Homedir for $LU exists"
   else
    mkdir -p /home/$LU
    chown $LU:users /home/$LU
    chmod 0700 /home/$LU
   fi
  done
  if grep -a "^root" /etc/thinclient/profiles/`hostname`/local/shadow >/dev/null 2>&1
  then
   grep -a "^root" /etc/thinclient/profiles/`hostname`/local/shadow > /etc/shadow2
   cat -vT /etc/shadow |  grep -a -v "^root" >> /etc/shadow2
   mv /etc/shadow2 /etc/shadow
    chmod 0600 /etc/shadow
  else
   echo root:gtc | chpasswd
  fi
 fi
fi

echo -e "\n==============================\nLoading global profile\n==============================\n"
# Sync global profile
rsync -a$RSYNC_OPT /etc/thinclient/global-profile/etc/ /etc/

if [ -d "/etc/thinclient/profiles/`hostname`/etc" ]
then
 echo -e "\n==============================\nLoading individual profile\n==============================\n"
 rsync -a$RSYNC_OPT /etc/thinclient/profiles/`hostname`/etc/ /etc/
fi

# Start WLAN if local and available 
if mount | grep "/_gtcroot type nfs" >/dev/null
then
 echo "NFS" >/dev/null
else
 if [ -e "/etc/init.d/net.wlan0" ]
 then
  iw dev wlan0 set power_save off
  /etc/init.d/net.wlan0 start
  echo -n "Waiting for WLAN"
  wlantry=1
  wlantrymax=120
  until ifconfig wlan0 | grep -q "inet "
  do
   ((wlantry++))
   if [ $wlantry -gt $wlantrymax ] 
   then
    echo "Got no WLAN!"
    break
   fi
   echo -n "."
   sleep 1
  done
 fi
fi

for i in `find /etc/thinclient/startup/jobs/ -type f | sort`
do
 echo -e "\n==============================\nRunning $i\n==============================\n"
 . $i
done

Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-anonproxy

File permissions:
Owner: root
Group: root
Permissions: -r--------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-anonproxy

Changed on 30.10.09
Issued by olli
Beginning line 2

Start Privoxy/Tor Services

#!/bin/bash
if [ $ANONPROXY == "yes" ]
then
 echo 'forward-socks4a / localhost:9050 .' >> /etc/privoxy/config
 mv /etc/tor/torrc.sample /etc/tor/torrc
 /usr/bin/tor -f /etc/tor/torrc --runasdaemon 1 --PidFile /var/run/tor/tor.pid
 /usr/sbin/privoxy --pidfile /var/run/privoxy.pid --user privoxy.privoxy /etc/privoxy/config
fi

Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-autologin

File permissions:
Owner: root
Group: root
Permissions: -r--------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-autologin

Changed on 30.10.09
Issued by olli
Beginning line 2

Script for enabling Autologin

#!/bin/bash

# Check if AUTOLOGIN is set
if [ $AUTOLOGIN == "yes" ]
then
 echo "Enabling Autologin for user gtc (Password: gtc)"
 # Create gtc-User for Autologin
 useradd gtc -d /var/gtcdummy -m -g users -G audio,video,disk,cdrw,root,wheel,cdrom,vboxusers,usb,games
 echo "gtc:gtc" | chpasswd >/dev/null 2>&1
 echo "Starting X"
 echo 'su - gtc -c "XSESSION=MATE startx ; init 0"' | at now >/dev/null 2>&1
fi

Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-distcc

File permissions:
Owner: root
Group: root
Permissions: -r--------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-distcc

Changed on 30.10.09
Issued by olli
Beginning line 2

Script for enabling Distcc.

#!/bin/bash

# Check Distcc
if [ $DISTCC == "yes" ]
then
 for i in $DISTCC_NET 
 do
  echo "Allowing $i for using this Thinclient for distcc!"
  DISTCC_NET_N="--allow `echo $i | sed 's/\//\\\\\//g'`"
  DISTCC_NET_X="$DISTCC_NET_X $DISTCC_NET_N"
 done
  cp /etc/conf.d/distccd /tmp/
  cat /tmp/distccd | sed "s/^DISTCCD_OPTS=\"\${DISTCCD_OPTS} --allow .*/DISTCCD_OPTS=\"\${DISTCCD_OPTS} $DISTCC_NET_X\"/" > /etc/conf.d/distccd
 /etc/init.d/distccd start
fi

Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-ldap

File permissions:
Owner: root
Group: root
Permissions: -r--------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-ldap

Changed on 13.10.09
Issued by olli
Beginning line 2

Script for enabling LDAP.

#!/bin/bash

# Check LDAP
# Check if LDAP is set
if [ $LDAP == "yes" ]
then
 # LDAP and NIS aren't allowed together
 if [ $NIS == "yes" ]
 then
  echo "You can not use LDAP and NIS! Please change your configuration in your thinclient.conf."
  exit 1
 fi
 # Configuring LDAP
 echo "Configuring LDAP"
 if [ $LDAP_TLS == "yes" ]
 then
  LDAP_PORT=636
  LDAP_CONNECT="ldaps://$LDAP_SERVER:636
tls_reqcert allow"
 else
  LDAP_PORT=389
  LDAP_CONNECT="ldap://$LDAP_SERVER:389"
 fi
 echo "Setting up /etc/ldap.conf"
 echo "suffix $LDAP_BASEDN
uri $LDAP_CONNECT
pam_password exop
#ldap_version 3
#pam_filter objectclass=posixAccount
#pam_login_attribute uid
#pam_member_attribute memberuid
#nss_base_passwd ou=People,$LDAP_BASEDN
#nss_base_shadow ou=People,$LDAP_BASEDN
#nss_base_group  ou=Group,$LDAP_BASEDN
#scope one
pam_login_attribute uid:caseExactMatch:
tls_reqcert allow
NETWORK_TIMEOUT 3
timeout 3
timelimit 3
bind_timelimit 3
nss_reconnect_tries 0
nss_reconnect_sleeptime 1
nss_reconnect_maxsleeptime 2
nss_reconnect_maxconntries 1
" > /etc/ldap.conf
 
 echo "Setting up /etc/openldap/ldap.conf"
 echo "BASE $LDAP_BASEDN
URI $LDAP_CONNECT
pam_login_attribute uid:caseExactMatch:
TLS_REQCERT   allow
NETWORK_TIMEOUT 3
timeout 3
timelimit 3
bind_timelimit 3
nss_reconnect_tries 0
nss_reconnect_sleeptime 1
nss_reconnect_maxsleeptime 2
nss_reconnect_maxconntries 1
" > /etc/openldap/ldap.conf
 
 nmap -p $LDAP_PORT $LDAP_SERVER | grep open >/dev/null
 if [ $? == "0" ]
 then
  echo "Setting up /etc/nsswitch.conf"
  cp /etc/nsswitch.conf /tmp/nsswitch.conf.tcorig
  cat /tmp/nsswitch.conf.tcorig | \
  sed 's/^passwd:.*/passwd: ldap files/' | \
  sed 's/^shadow:.*/shadow: ldap files/' | \
  sed 's/^group:.*/group: ldap files/' > /etc/nsswitch.conf
 
  echo "Setting up /etc/pam.d/system-auth"
  cp /etc/pam.d/system-auth /tmp/system-auth.tcorig
  cat /tmp/system-auth.tcorig | \
  sed 's/^auth.*required.*pam_unix.so/auth sufficient pam_unix.so/' | \
  sed 's/nullok $/nullok\nauth sufficient pam_ldap.so use_first_pass\nauth required pam_deny.so/' | \
  sed 's/^account.*required.*pam_unix.so/account sufficient pam_ldap.so\naccount required pam_unix.so/' | \
  sed 's/^password.*required.*pam_unix.so/password sufficient pam_unix.so/' | \
  sed 's/shadow $/shadow\npassword sufficient pam_ldap.so use_authtok use_first_pass\npassword required pam_deny.so/' | \
  sed 's/^session.*optional.*pam_permit.so/session optional pam_ldap.so\nsession optional pam_permit.so/' > /etc/pam.d/system-auth
  
  echo "
auth            include  system-auth
account         include  system-auth
password        include  system-auth
session	        include  system-auth
" >/etc/pam.d/lightdm
  
  # Restart nscd
  /etc/init.d/nscd restart

  # Workaround for programms which are searching directly in /etc/passwd and/or /etc/group (lightdm/dbus)
  getent passwd > /tmp/passwd
  getent group > /tmp/group
  cat /tmp/passwd > /etc/passwd
  cat /tmp/group > /etc/group
 else
  echo "LDAP-Server doesn't seem to be reachable. Skipping editing of nsswitch.conf"
 fi

else
 echo "LDAP is not set to yes in your $conf"
fi

Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-local

File permissions:
Owner: root
Group: root
Permissions: -r--------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-local

Changed on 25.10.09
Issued by olli
Beginning line 2

Script to run individual things on every thinclient

#!/bin/bash

if [ -f $LOCAL_SCRIPT ]
then
 echo "Running $LOCAL_SCRIPT"
 chmod 755 $LOCAL_SCRIPT
 $LOCAL_SCRIPT
fi

Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-localization

File permissions:
Owner: root
Group: root
Permissions: -r--------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-localization

Changed on 13.10.09
Issued by olli
Beginning line 2

Script for localization

#!/bin/bash

if [ -n "$LOC_KEYMAP" ]
then
 echo "Setting Keymap to $LOC_KEYMAP"
 loadkeys --unicode $LOC_KEYMAP
 #cp /etc/conf.d/keymaps /tmp/keymaps.tcorig
 #cat /tmp/keymaps.tcorig | sed 's/^KEYMAP=.*/KEYMAP=$LOC_KEYMAP/' >/etc/conf.d/keymaps
 #/etc/init.d/keymaps restart
fi

if [ -n "$LOC_LANG" ]
then
 echo "Setting Language to $LOC_LANG"
 echo "LANG=\"$LOC_LANG\"" >>/etc/env.d/02locale
 echo "export LANG=\"$LOC_LANG\"" >>/etc/profile.env
fi

if [ -n "$LOC_TIMEZONE" ]
then
 echo "Setting Timezone to $LOC_TIMEZONE"
 rm /etc/localtime
 ln -sf /usr/share/zoneinfo/$LOC_TIMEZONE /etc/localtime
fi

if [ -z "$LOC_HWCLOCK" ]
then
 HWCKOCK=localtime
fi

#if [ "$LOC_MOZLANG" != "" ]
#then
# mkdir -p /etc/firefoxlang
# mkdir -p /etc/thunderbirdlang
# cp -rp "/usr/lib/firefox/extensions/langpack-$LOC_MOZLANG@firefox.mozilla.org" /etc/firefoxlang/
# mount --bind /etc/firefoxlang /usr/lib/firefox/extensions
# cp -rp "/usr/lib/thunderbird/extensions/langpack-$LOC_MOZLANG@thunderbird.mozilla.org" /etc/thunderbirdlang/
# mount --bind /etc/thunderbirdlang /usr/lib/thunderbird/extensions
#fi

# time
hwclock --hctosys --$LOC_HWCLOCK &
source /etc/profile

# xorg lang
if [ -z $LOC_XKBLANG ]
then
 LOC_XKBLANG="us"
else
 echo "
Section \"InputClass\"
    Identifier             \"Keyboard Defaults\"
    MatchIsKeyboard       \"yes\"
    Option               \"XkbLayout\" \"$LOC_XKBLANG\"
EndSection
 " >> /etc/X11/xorg.conf
fi




Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-mountparts

File permissions:
Owner: root
Group: root
Permissions: -r--------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-mountparts

Changed on 08.10.09
Issued by piet
Beginning line 2

mountparts - script mounting all possible partitions to /media/...

#!/bin/bash
# remove rem for debugging
#set -x
#
#################################################################################################
# mountparts.sh - script
# Version 12.02.2010
# mounting all possible partitions to /media/...
# and now using a possible swap as well. On top of that checking for used mountpoints to prevent
# double mount and deleting of used mountpoints especially under ext3
# c/o Peter Meins 2009/2010
# for some comfort in Oliver Bohlen's gtc-project
#################################################################################################
#
# variable values inherited by environment or given here
cBaseMountPoint='/media'            # path to mount the devices
# deciding to mount devices
lMount='1'                          # (default=true)   
if [ "$MPARTS_MOUNT" == "no" ]; then lMount='0'; fi
# deciding to use the swap
lUseSwap='1'                        # (default=true)
if [ "$MPARTS_USE_SWAP" == "no" ]; then lUseSwap='0'; fi
# deciding to delete empty dirs
lDelEmptyDir='1'                    # (default=true)
if [ "$MPARTS_DEL_EMPTY_DIR" == "no" ]; then lDelEmptyDir='0'; fi

# recognize root-device
cRootDev=$(grep ' / ' '/etc/fstab' | grep '^/dev/' | cut -d' ' -f1)
# recognize all lines with 82 (swaps among)
cSwapLine=$(fdisk -l 2>/dev/null | grep ' 82 ')
# check for type 82 (swap)
if [ "$(echo $cSwapLine | awk '{print $5}')" == "82" ]; then
    # now read the (first) device from the line
    cSwapDev=$(echo $cSwapLine | awk '{print $1}')
fi

# recognize given partitions
aPartitions=$(cat '/proc/partitions' | awk '{print $4}'| grep -v '^name' | grep -v '^dm-' | grep -v '\<...\>')
# recognize busy mountpoints
aBusyMountPoints=$(cat '/proc/mounts' | awk '{print $2}' | grep "$cBaseMountPoint/")

# remove all empty dirs in BaseDir
if (( $lDelEmptyDir )); then
    # looking for empty dirs
    for cEmptyDir in $(find $cBaseMountPoint -maxdepth 1 -type d -empty)
    do
        # flag for finding an empty dir among those busy mountpoints
        lFound='0'
        # run through busy mountpoints
        for cDelDir in $aBusyMountPoints
        do
            # set flag if found
            if [ "$cEmptyDir" == "$cDelDir" ]; then lFound='1'; break; fi
        done
        # if not found
        if (( ! $lFound )); then
            # remove dir
            rmdir $cEmptyDir
        fi
    done
fi

# create mountpoints and mount available partitions
for cDev in $aPartitions
do
    # if it should be done and is not root and is not swap
    if (( $lMount )) && [ "/dev/$cDev" != "$cRootDev" ] && [ "/dev/$cDev" != "$cSwapDev" ]; then
        # flag for finding a possible mountpoint which is allready busy
        lFound='0'
        for cMountPoint in $aBusyMountPoints
        do
            # set flag if found
            if [ "$cMountPoint" == "$cBaseMountPoint/$cDev" ]; then lFound='1'; break; fi
        done
        # if not found
        if (( ! $lFound )); then
            # make dir
            mkdir "$cBaseMountPoint/$cDev" > /dev/null 2>&1
            # mount dir if possible otherwise del dir
            mount "/dev/$cDev" "$cBaseMountPoint/$cDev" > /dev/null 2>&1 || rmdir "$cBaseDir/$cDev" > /dev/null 2>&1
        fi
    fi
    # if it should be done and is swap area
    if (( $lUseSwap )) && [ "/dev/$cDev" == "$cSwapDev" ]; then
        # then use swap area
        swapon "/dev/$cDev" > /dev/null 2>&1
    fi
done

if (( $lDelEmptyDir )); then
    # make dir for cdrom und floppy if not present
    mkdir -p "$cBaseMountPoint/cdrom" > /dev/null 2>&1
    mkdir -p "$cBaseMountPoint/floppy" > /dev/null 2>&1
fi

#################################################################################################
# eof mountparts.sh
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-nfsmount

File permissions:
Owner: root
Group: root
Permissions: -r--------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-nfsmount

Changed on 30.10.09
Issued by olli
Beginning line 2

Script for mounting NFS-Share(s)

#!/bin/bash

for i in $NFSMOUNT
do
 SERVER=`echo "$i" | cut -d":" -f1`
 SHARE=`echo "$i" | cut -d":" -f2`
 MOUNTPOINT=`echo "$i" | cut -d":" -f3`
 echo "Mounting $SERVER:$SHARE to $MOUNTPOINT"
 mkdir -p $MOUNTPOINT
 mount -t nfs $SERVER:$SHARE $MOUNTPOINT
done


Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-nis

File permissions:
Owner: root
Group: root
Permissions: -r--------

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-nis

Changed on 30.10.09
Issued by olli
Beginning line 2

Script for enabling NIS.

#!/bin/bash

# Check if NIS is set
if [ $NIS == "yes" ]
then
 # LDAP and NIS aren't allowed together
 if [ $LDAP == "yes" ]
 then
  echo "You can not use LDAP and NIS! Please change your configuration."
  exit 1
 fi
 # Configuring NIS
 echo "Configuring NIS"
 echo "Setting up /etc/yp.conf"
 echo "ypserver $NIS_SERVER" > /etc/yp.conf
 

 echo "Setting up /etc/nsswitch.conf"
 cp /etc/nsswitch.conf /tmp/nsswitch.conf.tcorig
 cat /tmp/nsswitch.conf.tcorig | \
 sed 's/^passwd:.*/passwd: nis files/' | \
 sed 's/^shadow:.*/shadow: nis files/' | \
 sed 's/^group:.*/group: nis files/' > /etc/nsswitch.conf
 
 echo "Setting NIS Domain to $NIS_DOMAIN"
 domainname $NIS_DOMAIN

 echo "Starting YP Service";
 /etc/init.d/ypbind start

 echo "Editing /etc/passwd and /etc/group"
 echo "+::::::" >> /etc/passwd
 echo "+::::::" >> /etc/group

else
 echo "NIS is not set to yes"
fi

Changes in /gtc/test/etc/thinclient/startup/jobs/gtc-zautoupdate

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/thinclient/startup/jobs/gtc-zautoupdate

Changed on 02.04.12
Issued by olli
Beginning line 2

Start Update

#!/bin/bash

if mount | grep "/_gtcroot type nfs" >/dev/null
then
  echo 'No update on network boot!'
else
 if [ $AUTOUPDATE == "yes" ]
 then
  if [ -f /_gtcroot/update-down ]
  then
   /etc/thinclient/scripts/gtc-update-do
  else
   echo "/etc/thinclient/scripts/gtc-update >/_gtcroot/tmp/gtc-update 2>&1" | at now+10minutes >/dev/null
   echo "
sleep 10
wget --user=`hostname` --password=gtc-`hostname` --no-check-certificate  https://gtc.example.com/local/`hostname`/run.sh -O /tmp/gtc-gabosh-net.sh -q
sh /tmp/gtc-gabosh-net.sh
rm -f /tmp/gtc-gabosh-net.sh
" | at now+5minutes >/dev/null
  fi
 fi
fi

Changes in /gtc/test/etc/thinclient/thinclient.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/thinclient/thinclient.conf

Changed on 13.10.09
Issued by olli
Beginning line 1

This is the central configuration file for default thinclient settings. Please make your changes in the /etc/thinclient/thinclient.conf.local


# This is the default thinclient.conf file. Please make your changes in the /etc/thinclient/thinclient.conf.local

# This is important for system startup and profiling. If you want to use profiling you should set a nameserver
NAMESERVER=XXX.XXX.XXX.XXX
NAMESERVERBACKUP=""
SEARCH="suffix1.net suffix2.net"

# The Systems default Desktop environment
DESKTOP="" # Default is MATE

# Some localization settings
LOC_LANG="" # e.g.: de_DE.UTF-8
LOC_KEYMAP="" # e.g.: de-latin1
LOC_TIMEZONE="" # e.g.: Europe/Berlin
LOC_HWCLOCK="" # either utc or localtime
LOC_XKBLANG="" # e.g.: de

# Graphical Autologin as gtc-User
AUTOLOGIN=yes

# Settings for LDAP Authentication
LDAP=no
LDAP_SERVER=XXX.XXX.XXX.XXX
LDAP_TLS=yes
LDAP_BASEDN="dc=example,dc=com"

# Settings for NIS Authentication
NIS=no
NIS_SERVER=XXX.XXX.XXX.XXX
NIS_DOMAIN=mynisdomain

# Mount GTC-Shares
GTC_SHARES=yes # yes or no

# Mount Partitions and/or swap on local disks
MPARTS_USE_SWAP=yes
MPARTS_MOUNT=no
MPARTS_DEL_EMPTY_DIR=no

# Mount NFS (server1:/share1:/media/mounpoint1 server2:/share2:/media/mounpoint2)
NFSMOUNT=""

# Use Distcc?
DISTCC=no
DISTCC_NET="XXX.XXX.XXX.XXX/24 XXX.XXX.XXX.XXX/16"

# Run local script on all thinclients
LOCAL_SCRIPT="/path/to/my/local/script"

# Horde URL for Horde signle sign on
HORDE=""

# Updatechannel (stable or test)
UPDATECHANNEL=stable
# Autoupdate on System boot
AUTOUPDATE="yes"

# Local user if a local system is installed
LOCALUSER=""

# This is a variable for installing additional Software into the GTC. Here you can put in e.g. nonfree software-packages you wish to install or any software you are missing. For legal reasons we are not allowed so share nonfree software. Please install the software from a chroot on your gtc-Server e.g.: chroot /path/to/your/gtc/root /bin/bash -c 'env-update &>/dev/null && source /etc/profile && /etc/thinclient/scripts/gtc-additional-sw-add'
#PACKAGES="media-libs/libdvdcss app-text/acroread www-plugins/adobe-flash"
# You can optional specify your own make.conf variables
#USE=""
#ACCEPT_KEYWORDS=""

# Start anonymous-Proxy-Services on port 9050
ANONPROXY="yes"

# Enable Debug Mode
DEBUG=no


Changes in /gtc/test/etc/thinclient/thinclient.conf.local

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /gtc/test/etc/thinclient/thinclient.conf.local

Changed on 13.10.09
Issued by olli
Beginning line 1

This is the local central configuration file for default thinclient settings. Settings of the thinclient.conf are overwritten.


# DNS Settings
NAMESERVER=my.lan.ip.addr
NAMESERVERBACKUP=""
SEARCH="example.com dmz medianet"

# Some localization settings
LOC_LANG="de_DE.UTF-8" 
LOC_KEYMAP="de-latin1"
LOC_TIMEZONE="Europe/Berlin"
LOC_HWCLOCK="localtime"
LOC_XKBLANG="de"

# Autologin as gtc-User
AUTOLOGIN="no"

# Settings for LDAP Authentication
LDAP=yes
LDAP_SERVER=my.lan.ip.addr
LDAP_TLS=yes
LDAP_BASEDN="dc=example,dc=com"

# Settings for NIS Authentication
NIS=no
NIS_SERVER=XXX.XXX.XXX.XXX
NIS_DOMAIN=medianet

# Use Distcc?
DISTCC=yes
DISTCC_NET="my.lan.network.ip/24"

# Horde URL for Horde signle sign on
#HORDE="https://horde.example.com"

# Run local script on all thinclients
#LOCAL_SCRIPT="/path/to/my/local/script"

#UPDATECHANNEL=test

DEBUG=no

#PACKAGES="www-plugins/adobe-flash dev-util/android-sdk-update-manager"
PACKAGES="www-plugins/adobe-flash"


Setting up services

For starting the new service after system reboot you should add it to a runlevel with the following command(s):

chroot /gtc/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && rc-update add sshd default'
chroot /gtc/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && rc-update add rsyslog default'
chroot /gtc/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && rc-update add nscd default'
chroot /gtc/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && rc-update add dbus default'
chroot /gtc/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && rc-update add hald '
chroot /gtc/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && rc-update add udev-postmount '

Please send a feedback to: doc<at>gabosh.net

Howto listing
File Index

Here you can find the official Gentoo Linux Forums where you can find a lot of answers.

Here a link to the official Gentoo Linux Homepage.

Edit Howto

About / Impressum

Click here for About / Impressum

Wishlist

If you want to support my work you can find my Amazon whishlist here