summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorJonathan Bauer2013-02-20 16:07:49 +0100
committerJonathan Bauer2013-02-20 16:07:49 +0100
commita4fdf85a3fbf4c8efa414191aaacc59441ff045d (patch)
tree94eafe6594b6a0c741650abd5a7d764ff926ce01 /data
parent? (diff)
downloadtm-scripts-a4fdf85a3fbf4c8efa414191aaacc59441ff045d.tar.gz
tm-scripts-a4fdf85a3fbf4c8efa414191aaacc59441ff045d.tar.xz
tm-scripts-a4fdf85a3fbf4c8efa414191aaacc59441ff045d.zip
renaming
Diffstat (limited to 'data')
-rw-r--r--data/analyse-disk.sh120
-rw-r--r--data/fetch-config178
-rw-r--r--data/ip-dns-conf86
3 files changed, 384 insertions, 0 deletions
diff --git a/data/analyse-disk.sh b/data/analyse-disk.sh
new file mode 100644
index 00000000..0c152dbf
--- /dev/null
+++ b/data/analyse-disk.sh
@@ -0,0 +1,120 @@
+#!/bin/sh
+# Copyright (c) 2013 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found under http://openslx.org
+#
+# Local hard disk autoconfiguration script for OpenSLX linux stateless
+# clients, detecting swap and special partitions
+
+#############################################################################
+
+# Todo:
+# * This script should be run just once per boot!
+# * The activation of swap could/should be handled in separate script!?
+# * The mounting of /tmp could/should be done separately?
+# * Same for other partitions, use information of /etc/fstab for that?
+# * Should we just install xfs in the source system and boil down everything
+# onto that?
+
+# General formatter for the /tmp partition on a local harddisk
+diskfm () {
+local target=$1
+local mntpnt=$2
+local fs
+local path
+for fs in xfs reiserfs ext2 ; do
+ if strinfile "$fs" /proc/filesystems || modprobe ${MODPRV} $fs ; then
+ unset $found
+ for path in /sbin /bin /usr/sbin /usr/bin ; do
+ if test -x /mnt/$path/mkfs.$fs ; then
+ found=yes
+ case mkfs.$fs in
+ mkfs.xfs)
+ fopt="-f"
+ mopt="-o noexec"
+ ;;
+ mkfs.ext2)
+ fopt="-Fq"
+ mopt="-o nocheck,noexec"
+ ;;
+ mkfs.reiserfs)
+ fopt="-f"
+ mopt="-o noexec"
+ ;;
+ esac
+ mkfs.$fs $fopt $target >/dev/null 2>&1 #|| error
+ if [ -z $mntpnt ] ; then
+ umount /tmp 2>/dev/null
+ if mount -t $fs -n $mopt $target /tmp 2>/dev/null; then
+ return 0
+ else
+ mount -n -t tmpfs none /tmp
+ fi
+ else
+ mkdir -p $mntpnt
+ mount -t $fs -n -o loop $target $mntpnt 2>/dev/null
+ return 0
+ fi
+ fi
+ done
+ [ -z $found ] && continue
+ else break
+ fi
+done
+}
+
+# Check for local harddisks and appropriate partitions
+fdisk -l /dev/$hd|sed -n "/^\/dev\//p" >/etc/disk.partition
+
+# Check for standard swap partitions and make them available to the system
+for hdpartnr in $(cat /etc/disk.partition | \
+ sed -n -e "/ 82 /p"|sed -e "s/[[:space:]].*//") ; do
+ echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >>/etc/fstab
+done
+
+# We use special non assigned partition type (id44) for harddisk scratch
+# space, thus no normal filesystem will be incidentally deleted or
+# corrupted
+for hdpartnr in $(cat /etc/disk.partition | \
+ sed -n -e "/ 44 /p"|sed -e "s/[[:space:]].*//") ; do
+ # check for supported filesystem and formatter
+ ( if diskfm $hdpartnr ; then
+ echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
+ echo -e "$hdpartnr\t/tmp\t\tauto\t\tdefaults\t 0 0" >>/etc/fstab
+ else
+ echo "formatting failed for some reason ($(sysup))" >/tmp/tmpready
+ fi ) &
+ break
+done
+
+# Put detected linux partitions (83) into /etc/fstab with "noauto", special
+# partition 45 (persistent scratch) to /var/scratch and 46 to /var/openslx
+for partid in 83 45 46 ; do
+ for hdpartnr in $(cat /etc/disk.partition | \
+ sed -n -e "/ ${partid} /p"|sed -e "s/[[:space:]].*//") ; do
+ mkdir -p /media/${hdpartnr#/dev/*} 2>/dev/null
+ if [ ${partid} -eq 83 ] ; then
+ echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,\
+noexec\t 0 0" >>/tmp/fstab
+ elif [ ${partid} -eq 45 ] ; then
+ #mount -t auto ${hdpartnr} /media/${hdpartnr#/dev/*}
+ #ln -sf /media/${hdpartnr#/dev/*} /var/scratch
+ echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\
+\t\t 0 0" >>/tmp/fstab
+ elif [ ${partid} -eq 46 ] ; then
+ # Mount a home directory to (/mnt)/var/home
+ #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\
+ #test -d /mnt/media/${hdpartnr#/dev/*}/home && \
+ # ln -sf /media/${hdpartnr#/dev/*} /var/home
+ echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\
+\t\t 0 0" >>/tmp/fstab
+ fi
+ done
+done
+
diff --git a/data/fetch-config b/data/fetch-config
new file mode 100644
index 00000000..556f0f41
--- /dev/null
+++ b/data/fetch-config
@@ -0,0 +1,178 @@
+#!/bin/sh
+# Copyright (c) 2013 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found under http://openslx.org
+#
+# Fetch configuration from server ...
+
+#############################################################################
+
+# Depends on configured networking, provides configuration
+
+
+# Todo: rewrite for next-gen system - principle would be the same ...
+
+# Function for retrieving configuration file (machine-setup) via tftp from a
+# predefined server or given source (file=tftp-server:/path via kernel
+# command line)
+unpack () {
+# $1 is config file name to get, $2 IP of server to get file from
+local dst=$1
+if [ -s $dst ] ; then
+ # fixme: handle different types of packaging (gzip/bzip2)??
+ if ! tar -xpzf $dst 2> /tmp/ConfTGZ-tar-error ; then
+ cat /tmp/ConfTGZ-tar-error
+ error "$unpack_ConfTGZ" nonfatal
+ rm /tmp/ConfTGZ-tar-error
+ fi
+ [ "$DEBUGLEVEL" -le 2 -o "$DEBUGLEVEL" -eq 8 ] && rm $dst
+ return 0
+else
+ return 1
+fi
+}
+
+# tftp wrapper
+# usage tftp_get <path> <tftpdserver> [count]
+# count is optional - default is 3 - use -1 for indefinit
+tftp_get () {
+ local file="$1"
+ local file_server="$2"
+ local download_successful=0
+ local countdown="$3"
+
+ if [ -z "$1" -o -z "$2" ]; then
+ [ $DEBUGLEVEL -ge 1 ] && \
+ echo "[tftp_get] Usage: tftp_get <path> <server> [count]"
+ return 1;
+ fi
+
+ [ "$countdown" = "" ] && countdown=3
+
+ until [ $download_successful -eq 1 ]
+ do
+ if [ "$countdown" = "0" ]; then
+ [ $DEBUGLEVEL -ge 1 ] && \
+ echo "[tftp_get] download of \"$file\" from \"$file_server\" ... failed"
+ return 0;
+ fi
+ tftp -g -r "/$file" -l /tmp/$(basename $file) $file_server
+ [ -s /tmp/$(basename $file) ] && download_successful=1
+ countdown=$(expr $countdown - 1)
+ usleep 200000
+ done
+ [ $DEBUGLEVEL -ge 1 ] && \
+ echo "[tftp_get] download of \"$file\" from \"$file_server\" ... successful"
+ return 0;
+}
+
+
+# wget wrapper
+# usage wget_get <path> <ftp/httpserver> [count]
+# count is optional - default is 3 - use -1 for indefinit
+wget_get () {
+ local file="$1"
+ local file_server="$2"
+ local download_successful=0
+ local countdown="$3"
+
+ if [ -z "$1" -o -z "$2" ]; then
+ [ $DEBUGLEVEL -ge 1 ] && \
+ echo "[wget_get] Usage: wget_get <path> <server> [count]"
+ return 1;
+ fi
+
+ [ "$countdown" = "" ] && countdown=3
+
+ until [ $download_successful -eq 1 ]
+ do
+ if [ "$countdown" = "0" ]; then
+ [ $DEBUGLEVEL -ge 1 ] && \
+ echo "[wget_get] download of \"$file\" from \"$file_server\" ... failed"
+ return 0;
+ fi
+ wget -q $file_server$file -O /tmp/$(basename $file)
+ [ -s /tmp/$(basename $file) ] && download_successful=1
+ countdown=$(expr $countdown - 1)
+ usleep 200000
+ done
+ [ $DEBUGLEVEL -ge 1 ] && \
+ echo "[wget_get] download of \"$file\" from \"$file_server\" ... successful"
+ return 0;
+}
+
+
+fileget () {
+# normally tftp would be used, alternatively use wget for ftp or http
+# if local device file is specified - mount and unmount after copying
+local cfgfile
+[ "x$fileprot" = "x" ] && fileprot=tftp
+if [ "x$filepath" != "x" ] ; then
+ cfgfile=${filepath}
+ [ "x$fileserv" = "x" ] && fileserv=$(checkip ${serverip})
+ # wait for dns if "fileserv" is a name and not lbd device
+ [ "$fileprot" != "lbd" ] && \
+ echo ${fileserv} | grep -qi [a-z]
+ [ $DEBUGLEVEL -ge 1 ] && echo "fileget - fileprot:$fileprot, filepath:\
+$filepath, fileserv:$fileserv" >>$LOGFILE
+ case "$fileprot" in
+ ftp|http)
+ wget_get $cfgfile $fileprot://$fileserv \
+ && { unpack /tmp/$(basename $cfgfile) && break; } 2>>$LOGFILE
+ ;;
+ lbd)
+ local ldev=$fileserv
+ echo "Waiting for configuration file ${cfgfile} ...."
+ [ $DEBUGLEVEL -ge 1 ] && echo "fileget - fileprot:$fileprot, filepath:\
+$filepath, fileserv:$fileserv" >>$LOGFILE
+ waitfor /mnt/${cfgfile} 10000
+ if [ -f /mnt/${cfgfile} ]; then
+ unpack /mnt/$cfgfile
+ else
+ error "$init_errlfg"
+ fi
+ ;;
+ *)
+ tftp_get $cfgfile $fileserv \
+ && unpack /tmp/$(basename $cfgfile) 2>>$LOGFILE
+ ;;
+ esac
+else
+ # predefined value for OpenSLX environment; it is expected that this
+ # directory is just below the tftpboot (path to which the daemon is
+ # restricted to)
+ filepath="client-config"
+ [ "x$fileserv" = "x" ] && fileserv=$(checkip ${serverip})
+ [ $DEBUGLEVEL -ge 1 ] && echo "fileget - fileprot:$fileprot, filepath:\
+$filepath, fileserv:$fileserv" >>$LOGFILE
+ # try to get configuration files successively; start with distro client
+ # and try last distro default ...
+ mac=$(echo $macaddr|sed "s/:/-/g")
+ for cfgfile in ${filepath}/${SYSTEM_NAME}/01-$mac.tgz \
+ ${filepath}/${SYSTEM_NAME}/default.tgz ; do
+ case "$fileprot" in
+ ftp|http)
+ wget $fileprot://$fileserv/$cfgfile -O /tmp/$(basename $cfgfile) \
+ 2>>$LOGFILE && { unpack /tmp/$(basename $cfgfile) && break; }
+ ;;
+ tftp)
+ tftp_get $cfgfile $fileserv \
+ 2>>$LOGFILE && { unpack /tmp/$(basename $cfgfile) && break; }
+ ;;
+ esac
+ done
+ echo -e "\n## Configuration via fileget from ${fileprot}://${fileserv}/\
+${cfgfile}\n# Hierarchy is distro client and as last distro/default" \
+ >>/tmp/confviafile
+fi
+cat /initramfs/machine-setup >>/tmp/confviafile 2>/dev/null || \
+ error "$nomachsetup"
+echo "fileget via $fileprot from $fileserv/$cfgfile finished" >/tmp/file-done
+[ $DEBUGLEVEL -ge 1 ] && echo "fileget from $cfgfile finished" >>$LOGFILE
+}
diff --git a/data/ip-dns-conf b/data/ip-dns-conf
new file mode 100644
index 00000000..f14ecd88
--- /dev/null
+++ b/data/ip-dns-conf
@@ -0,0 +1,86 @@
+#!/bin/sh
+# Copyright (c) 2013 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found under http://openslx.org
+#
+# Set IP and DNS configuration ...
+
+#############################################################################
+
+# Depends on running network interface, provides IP and DNS configuration
+
+# Dns and ip configuration, hostname of the machine --> to be merged with udhcpc.default.script!!
+echo "$host_name" >/proc/sys/kernel/hostname
+echo -e "# /etc/hosts - file generated by $0 during OpenSLX stage3\
+\n#\n# IP-Address Full-Qualified-Hostname Short-Hostname\n#\n\
+127.0.0.1\tlocalhost\n::1\t\tlocalhost ipv6-localhost ipv6-loopback\n\
+fe00::0\t\tipv6-localnet\nff00::0\t\tipv6-mcastprefix\nff02::1\
+\t\tipv6-allnodes\nff02::2\t\tipv6-allrouters\nff02::3\t\t\
+ipv6-allhosts\n" >/etc/hosts
+if [ -n "${domain_name}" ]; then
+ echo -en "${clientip}\t" >>/etc/hosts
+ for name in ${domain_name}; do
+ echo -en "${host_name}.${name} " >>/etc/hosts
+ done
+ echo -e "${host_name}" >>/etc/hosts
+else
+ echo -e "${clientip}\t${host_name}" >>/etc/hosts
+fi
+# set up domainname and resolving
+#rm -rf /etc/resolv.conf
+
+out=/etc/resolv.conf
+echo -e "# /etc/resolv.conf - file generated by\n#\t$0:\n\
+#\t${date}\n#options timeout:1 attempts:1 rotate" > $out
+
+[ "x${domain_name}" != "x" ] && echo -e "domain ${domain_name}" >> $out
+[ "x${domain_search}" != "x" ] && echo -e "search ${domain_search}" >> $out
+# fallback
+[ "x${domain_search}" == "x" ] && [ "x${domain_name}" != "x" ] && \
+ echo -e "search ${domain_name}" >> $out
+
+[ -n "${domain_name_servers}" ] && {
+ for name in ${domain_name_servers}; do
+ echo nameserver ${name} >> $out;
+ done; }
+
+# Create hostname file
+[ -n ${host_name} ] && [ -n ${domain_name} ] && \
+ echo "${host_name}.${domain_name}" > /etc/hostname
+
+
+# Set greeting and add information on booted system
+len=$(expr length ${SLXVERSION}${SYSTEM_NAME})
+if [ $len -le 28 ] ; then
+ vdstr="Stateless Workstation (V${SLXVERSION}/${SYSTEM_NAME})"
+ smax=28
+else
+ vdstr="V${SLXVERSION}/${SYSTEM_NAME}"
+ smax=52
+fi
+while [ $len -le $smax ] ; do
+ vdstr="$vdstr "
+ len=$(($len + 1))
+done
+len=$(expr length ${host_name})
+while [ $len -le 30 ] ; do
+ space="$space "
+ len=$(($len + 1))
+done
+echo "
+ WELCOME TO $space \n (\l)
+ _____ ______ ______ __ __ _______ __ __ __
+ / _ | _ | ___| | | | | ____| | | | | |
+ | | | | |_| | |_ | | | | |___ | | / /
+ | | | | ___/| _| | | ____ | | | |
+ | |_| | | | |___| | | | ____| | |___ / /
+ _____/|__| |______|__| |__| |_______|______|__| |__|
+
+ $vdstr (c) <OpenSLX.ORG>
+" >/etc/issue