summaryrefslogtreecommitdiffstats
path: root/server/modules/partitioner/opt/openslx/scripts/partitioner
diff options
context:
space:
mode:
Diffstat (limited to 'server/modules/partitioner/opt/openslx/scripts/partitioner')
-rwxr-xr-xserver/modules/partitioner/opt/openslx/scripts/partitioner83
1 files changed, 48 insertions, 35 deletions
diff --git a/server/modules/partitioner/opt/openslx/scripts/partitioner b/server/modules/partitioner/opt/openslx/scripts/partitioner
index e5e94f4e..03b30442 100755
--- a/server/modules/partitioner/opt/openslx/scripts/partitioner
+++ b/server/modules/partitioner/opt/openslx/scripts/partitioner
@@ -3,7 +3,8 @@
# set -e
PARTITIONSPATH="/proc/partitions"
-CONFIGPATH="/opt/openslx/config"
+CONFIGPATH="./config"
+# CONFIGPATH="/opt/openslx/config"
# BLOCKSIZE=$(sfdisk -l /dev/$CHOSENDISK | grep -o -e "blocks of [0-9]* bytes" | cut -d ' ' -f3)
BLOCKSIZE=1024
@@ -19,6 +20,10 @@ if [ -z "$DISKS" ]; then
exit 1
fi
if [ -z "$SLX_CHOOSEN_DISK" ]; then
+ if [ $SLX_AUTOMATIC_PARTITIONING = "yes" ]; then
+ dialog --msgbox "ERROR: You didn' define any hard disk in your configuration file." 10 40
+ exit 1
+ fi
DIALOGSTR="This computer has the following partitions:\n"
for disk in $DISKS; do
DISKSIZE=$(($(cat $PARTITIONSPATH | grep -e $disk$ | tr -s ' ' | cut -d ' ' -f4)*$BLOCKSIZE))
@@ -63,33 +68,39 @@ if [ -z "$SLX_CHOOSEN_DISK" ]; then
exit 1
fi
fi
+if [ -z "$SLX_PARTITION_TABLE" ]; then
+ if [ $SLX_AUTOMATIC_PARTITIONING = "yes" ]; then
+ SLX_PARTITION_TABLE='
+ 44,10G,/tmp
+ 45,10G,/var/scratch'
+ else
+ dialog --msgbox "ERROR: You didn't set a valid partition table. Please check your config file." 10 40
+ exit 1
+ fi
+fi
+
# if SLX_PARTITION_TABLE is set then put his content in a associative array
declare -A PARTTBL
COUNTER=1
-if [ -n "$SLX_PARTITION_TABLE" ]; then
- for PARTITION in $SLX_PARTITION_TABLE; do
- IFS=,
- set $PARTITION
- if [ $COUNTER -eq 4 ]; then
- COUNTER=$(($COUNTER+1))
- fi
- PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/id"]=$1
- PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/size"]=$(echo $2 | egrep -o "[0-9]*")
- PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/mountpoint"]=$3
- if [ -e $4 ]; then
- PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/bootable"]=0
- else
- PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/bootable"]=1
- fi
- # set the partitions to non-existents
- PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/exists"]=0
+for PARTITION in $SLX_PARTITION_TABLE; do
+ IFS=,
+ set $PARTITION
+ if [ $COUNTER -eq 4 ]; then
COUNTER=$(($COUNTER+1))
- done
- unset IFS
-else
- dialog --msgbox "ERROR: You didn't set a valid partition table. Please check your config file." 10 40
- exit 1
-fi
+ fi
+ PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/id"]=$1
+ PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/size"]=$(echo $2 | egrep -o "[0-9]*")
+ PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/mountpoint"]=$3
+ if [ -e $4 ]; then
+ PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/bootable"]=0
+ else
+ PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/bootable"]=1
+ fi
+ # set the partitions to non-existents
+ PARTTBL["$SLX_CHOOSEN_DISK$COUNTER/exists"]=0
+ COUNTER=$(($COUNTER+1))
+done
+unset IFS
# PARTTBL starts at 1 and ends at COUNTER-1
# check if the choosen disk is greater than the new partition table size.
@@ -101,7 +112,6 @@ for (( i = 1; i < $COUNTER; i++ )); do
fi
done
NEEDED_SPACE=$(($NEEDED_SPACE*1024*1024*1024+$COUNTER*1024*1024))
-echo "$DISKSIZE -lt $NEEDED_SPACE"
if [ $DISKSIZE -lt $NEEDED_SPACE ]; then
dialog --msgbox "ERROR: Insufficient space in disk /dev/$SLX_CHOOSEN_DISK." 6 40
exit 1
@@ -109,15 +119,18 @@ fi
# choosing the partition type (MSDOS or GPT) if it wasn't set in config file
if [ -z "$SLX_PARTITION_TYPE" ]; then
- SLX_PARTITION_TYPE=msdos
- ANS=$(dialog --no-tags --menu "Choose the partitions type" 0 0 0 "1" " MSDOS " "2" " GPT " 3>&1 1>&2 2>&3)
- if [ $? -eq 1 ]; then
- exit 1
- fi
- if [ $ANS -eq 1 ]; then
+ if [ $SLX_AUTOMATIC_PARTITIONING = "yes" ]; then
SLX_PARTITION_TYPE=msdos
else
- SLX_PARTITION_TYPE=GPT
+ ANS=$(dialog --no-tags --menu "Choose the partitions type" 0 0 0 "1" " MSDOS " "2" " GPT " 3>&1 1>&2 2>&3)
+ if [ $? -eq 1 ]; then
+ exit 1
+ fi
+ if [ $ANS -eq 1 ]; then
+ SLX_PARTITION_TYPE=msdos
+ else
+ SLX_PARTITION_TYPE=GPT
+ fi
fi
fi
@@ -140,7 +153,7 @@ DIALOGSTR=$DIALOGSTR" Free $FREESPACE ($GBSIZE GB)\n\n"
DIALOGSTR=$DIALOGSTR"All /dev/$SLX_CHOOSEN_DISK partitions will be deleted, ok?"
# asking confirmation to create the partitions
-if [[ $SLX_AUTOMATIC_PARTITIONING = "no" && SLX_DELETE_PARTITION_TABLE = 'yes' ]]; then
+if [[ $SLX_AUTOMATIC_PARTITIONING = "no" && $SLX_DELETE_PARTITION_TABLE = 'yes' ]]; then
dialog --defaultno --yesno "$DIALOGSTR" 0 0
if [ $? -eq 1 ]; then
exit 1
@@ -188,7 +201,7 @@ elif [ $(sfdisk -d /dev/$SLX_CHOOSEN_DISK 2> /dev/null | grep $SLX_CHOOSEN_DISK'
for (( i = 1; i < $COUNTER; i++ )); do
if [ $i -ne 4 ]; then
if [ ${PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]} = 0 ]; then
- sgdisk /dev/$SLX_CHOOSEN_DISK -i ${PART:3} | grep ${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}"000000-0000-0000-0000-000000000000" > /dev/null
+ sgdisk /dev/$SLX_CHOOSEN_DISK -i ${PART:3} 2> /dev/null | grep ${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}"000000-0000-0000-0000-000000000000" > /dev/null
if [ $? -eq 0 ]; then
echo "the partition $PART is the ${PARTTBL["$SLX_CHOOSEN_DISK$i/mountpoint"]} partition."
PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]=$PART
@@ -243,7 +256,7 @@ if [ $SLX_PARTITION_TYPE = 'GPT' ]; then
CMD=$CMD" -c "$i":\""${PARTTBL["$SLX_CHOOSEN_DISK$i/mountpoint"]}"\""
fi
done
- CMD=$CMD" > /dev/null"
+ CMD=$CMD" > /dev/null 2> /dev/null"
$CMD
for (( i = 1; i < $COUNTER; i++ )); do