summaryrefslogtreecommitdiffstats
path: root/core/modules/gdisk/data/inc/setup_gpt.differentapproach
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/gdisk/data/inc/setup_gpt.differentapproach')
-rwxr-xr-xcore/modules/gdisk/data/inc/setup_gpt.differentapproach157
1 files changed, 157 insertions, 0 deletions
diff --git a/core/modules/gdisk/data/inc/setup_gpt.differentapproach b/core/modules/gdisk/data/inc/setup_gpt.differentapproach
new file mode 100755
index 00000000..25b8dda3
--- /dev/null
+++ b/core/modules/gdisk/data/inc/setup_gpt.differentapproach
@@ -0,0 +1,157 @@
+#!/bin/ash
+# Copyright (c) 2014 - 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 special GPT partitions
+
+#############################################################################
+
+# Patition IDs
+# Prefix for all paritions is 0FC63DAF-8483-4772-8E79-9999999999
+# Suffix:
+# 44: non-persistent scratch partition
+# 45: persistent partiton
+# 46: non-persistent openslx partition for config, overlayfs and qcow images
+
+# We use special non assigned partition type for harddisk scratch
+# space, thus no normal filesystem will be incidentally deleted or
+# corrupted
+
+PREFIX=/mnt
+
+# Set disks to none
+ID44=
+ID45=
+ID46=
+
+# Mountpoints
+ID44MNT=/tmp
+ID45MNT=/opt/openslx/mnt/persistent
+ID46MNT=/opt/openslx/mnt/non-persistent
+
+# General formatter for the /tmp partition on a local harddisk
+diskfm () {
+ mopt="" # Global var!
+ local target="$1"
+ local fslist="xfs jfs ext4"
+ local fs
+ local path
+ [ $# -ge 2 ] && fslist="$2"
+ for fs in $fslist ; 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="-fq"
+ ;;
+ mkfs.jfs)
+ fopt="-q"
+ ;;
+ mkfs.ext4)
+ fopt="-Fq"
+ ;;
+ esac
+ mkfs.$fs ${fopt} "${target}"
+ fi
+ [ -n "$found" ] && break
+ fi
+ done
+}
+
+# Format and mount ID44 (/tmp)
+mount_id44 () {
+ HAVE_TMP=no
+ if echo $ID44 | grep -q '/dev/disk/'
+ then
+ # check for supported filesystem and formatter
+ if diskfm $ID44; then
+ mkdir -p $PREFIX$ID44MNT
+ if mount -t auto "$ID44" "$PREFIX$ID44MNT" 2>/dev/null
+ then
+ chmod a+rwxt $PREFIX$ID44MNT
+ echo -e "$ID44\t$ID44MNT\tauto\tnoexec\t0 0" >> "/etc/fstab"
+ HAVE_TMP=yes
+ else
+ echo "Could not mount partition $ID44"
+ fi
+ else
+ echo "Could not format partition $ID44"
+ fi
+ fi
+}
+
+# Mount persistent partition 45
+mount_id45 () {
+ HAVE_PERSISTENT=no
+ if echo $ID45 | grep -q '/dev/disk/'
+ then
+ mkdir -p $PREFIX$ID45MNT
+ if mount -t auto "$ID45" "$PREFIX$ID45MNT" 2>/dev/null
+ then
+ echo -e "$ID45\t$ID45MNT\tauto\tnoauto\t0 0" >> "/etc/fstab"
+ HAVE_PERSISTENT=yes
+ else
+ echo "Could not mount persistent partition $ID45"
+ fi
+ fi
+}
+
+# Mount non-persistent partition 46
+mount_id46 () {
+ HAVE_NONPERSISTENT=no
+ if echo $ID46 | grep -q '/dev/disk/'
+ then
+ # check for supported filesystem and formatter
+ if diskfm $ID46; then
+ mkdir -p $PREFIX$ID46MNT
+ if mount -t auto -o noexec "$ID46" "$PREFIX$ID46MNT" 2>/dev/null
+ then
+ echo -e "$ID46\t$ID46MNT\tauto\tnoauto,noexec\t0 0" >> "/etc/fstab"
+ HAVE_NONPERSISTENT=yes
+ else
+ echo "Could not mount non-persistent partition $ID46"
+ fi
+ else
+ echo "Could not format partition $ID44"
+ fi
+ fi
+}
+
+# Get partition types
+hdisks=$(ls /dev/disk/by-path/*-part[0-9]* \
+ | sed -re "s,(.*)-part[0-9]*,\1," \
+ | sort -u)
+
+if echo $hdisks | grep -q '/dev/disk/'
+ then
+ for hd in $(echo $hdisks)
+ do
+ upartid=$(sgdisk -p $hd 2>/dev/null | awk '$6~/FFFF/ {print $1}')
+ for upt in $(echo $upartid)
+ do
+ echo "${hd}-part${upt} $(sgdisk -i $upt $hd)" \
+ | awk '$5 ~ /0FC63DAF-8483-4772-8E79-[0]{10}4[4-6]/ \
+ {print $5 "=" $1}' \
+ | sed -re "s,0FC63DAF-8483-4772-8E79-[0]{10},ID," \
+ >> /etc/hdisks.conf
+ done
+ done
+ [ -r /etc/hdisks.conf ] && . /etc/hdisks.conf
+
+fi
+