summaryrefslogtreecommitdiffstats
path: root/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk
diff options
context:
space:
mode:
authorJonathan Bauer2013-07-31 17:24:27 +0200
committerJonathan Bauer2013-07-31 17:24:27 +0200
commit9b9842346d3cbde1a07039575b6fd5ad05fbdb90 (patch)
treec09a9aca3d2b1736e67d809c8252d9a53b4c78e6 /remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk
parentadded download of config.tgz to activate-sysconfig and moved it to stage31 (diff)
downloadtm-scripts-9b9842346d3cbde1a07039575b6fd5ad05fbdb90.tar.gz
tm-scripts-9b9842346d3cbde1a07039575b6fd5ad05fbdb90.tar.xz
tm-scripts-9b9842346d3cbde1a07039575b6fd5ad05fbdb90.zip
restructuring
Diffstat (limited to 'remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk')
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk111
1 files changed, 111 insertions, 0 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk
new file mode 100755
index 00000000..f162ec3a
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk
@@ -0,0 +1,111 @@
+#!/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 "${fs}" && available=yes;;
+ esac
+ if [ -n "${available}" ]; then
+ unset found
+ if which "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}"
+ fi
+ [ -n "$found" ] && break
+ fi
+done
+}
+
+# Check for local harddisks and appropriate partitions
+for waiting in 1 1 2 3 4; do
+ fdisk -l | sed -n "/^\/dev\//p" > "/etc/disk.partition"
+ [ -s "/etc/disk.partition" ] && break
+ sleep "$waiting"
+done
+echo "Partitions:"
+cat "/etc/disk.partition"
+
+# Check for standard swap partitions and make them available to the system
+for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
+ echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab"
+ swapon "$hdpartnr"
+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 $(sed -n -e "/ 44 /p" "/etc/disk.partition" | 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"
+ mkdir -p /tmptmp
+ mv /tmp/* /tmp/.* /tmptmp/
+ mount "$hdpartnr" /tmp
+ chmod a+rwxt /tmp
+ mv /tmptmp/* /tmptmp/.* /tmp/
+ rmdir /tmptmp
+ break
+ else
+ echo "formatting failed for some reason"
+ fi # Made this non-forking, systemd should handle it - 2013-05-28
+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 $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
+ mkdir -p "/media/${hdpartnr#/dev/*}"
+ if [ "${partid}" -eq 83 ]; then
+ echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/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" >> "/etc/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" >> "/etc/fstab"
+ fi
+ done
+done
+
+mount -a
+