summaryrefslogtreecommitdiffstats
path: root/remote/rootfs/rootfs-stage32/data/opt/openslx/bin
diff options
context:
space:
mode:
authorJonathan Bauer2013-05-23 13:39:18 +0200
committerJonathan Bauer2013-05-23 13:39:18 +0200
commit978a9595ee2226c5ab0b5fd360e6279d615f5bf1 (patch)
treef27eb47f453e60356367d1f09bed37b8874e2b34 /remote/rootfs/rootfs-stage32/data/opt/openslx/bin
parentfix annoying error message of 'which apt-get' on suse (diff)
downloadtm-scripts-978a9595ee2226c5ab0b5fd360e6279d615f5bf1.tar.gz
tm-scripts-978a9595ee2226c5ab0b5fd360e6279d615f5bf1.tar.xz
tm-scripts-978a9595ee2226c5ab0b5fd360e6279d615f5bf1.zip
tmp mount a-la openslx
Diffstat (limited to 'remote/rootfs/rootfs-stage32/data/opt/openslx/bin')
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/bin/analyse-disk105
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/bin/disk-tmp24
2 files changed, 129 insertions, 0 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/analyse-disk b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/analyse-disk
new file mode 100755
index 00000000..27c3f306
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/analyse-disk
@@ -0,0 +1,105 @@
+#!/bin/bash
+# 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 autodetection script for OpenSLX linux stateless clients,
+# detecting swap and special partitions
+
+#############################################################################
+
+# General formatter for the /tmp partition on a local harddisk
+diskfm () {
+local target=$1
+local fs
+local path
+for fs in xfs ext3 ext2 ; do
+ unset available
+ case $(cat /proc/filesystems) in
+ *${fs}*) available=yes;;
+ *) modprobe -q ${fs} 2>/dev/null && available=yes;;
+ esac
+ if [ -n ${available} ]; then
+ unset found
+ for path in /sbin /bin /usr/sbin /usr/bin /openslx/sbin /openslx/bin; do
+ if test -x /$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
+ mkdir -p /run/mount/tmp
+ mount -t ${fs} ${target} /run/mount/tmp
+ fi
+ done
+ [ -n "$found" ] && break
+ fi
+done
+}
+
+# Check for local harddisks and appropriate partitions
+fdisk -l |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\tnoauto\t\tdefaults\t 0 0" >>/etc/fstab
+ else
+ echo "formatting failed for some reason " >/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/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/disk-tmp b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/disk-tmp
new file mode 100755
index 00000000..4378c45c
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/disk-tmp
@@ -0,0 +1,24 @@
+#!/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
+#
+# Mount local ID44 partition to /tmp after all existing stuff is preserved
+
+#############################################################################
+
+# Check if ID44 is available by analysing /etc/fstab for appropriate entry
+if cat /proc/mounts | grep -qe "/dev/.*/tmp" ; then
+ mkdir -p /run/tmp
+ mv /tmp/* /run/tmp
+ mount --bind /run/mount/tmp /tmp
+ umount /run/mount/tmp
+ mv /run/tmp/* /tmp
+ rmdir /run/tmp
+fi