aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.d/controller/modules/functions/ct_newsys.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/config.d/controller/modules/functions/ct_newsys.sh b/config.d/controller/modules/functions/ct_newsys.sh
new file mode 100644
index 0000000..ee44d97
--- /dev/null
+++ b/config.d/controller/modules/functions/ct_newsys.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+_bsu_dfs() {
+ #/DEV/SDX
+ SYSDEV="$(blkid | grep "SYSFS" | awk -F ':' '{ print $1 }')"
+ BACKUPDEV="$(blkid | grep "BACKUPFS" | awk -F ':' '{ print $1 }')"
+ BOOTDEV="$(blkid | grep "BOOTFS" | awk -F ':' '{ print $1 }')"
+ USERDATADEV="$(blkid | grep "USERDATAFS" | awk -F ':' '{ print $1 }')"
+
+ export SYSDEV
+ export BACKUPDEV
+ export USERDATADEV
+ export BOOTDEV
+
+ # EXPORT SYSTEM'S FS
+ SYSFS="$(blkid | grep "LABEL=\"SYSFS\"" | awk -F ' ' '{print $4}' | awk -F '=' '{print $2}' | sed 's/\"//g')"
+ export SYS
+
+ # EXPORT BACKUP's FS
+ BACKUPFS="$(blkid | grep "LABEL=\"BACKUPFS\"" | awk -F ' ' '{print $4}' | awk -F '=' '{print $2}' | sed 's/\"//g')"
+ export BACKUPFS
+}
+
+_remake() {
+ if eval "mkfs.$1" "$2" "$3" "$4"; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+_remake_dev() {
+ if _unmount "$1"; then
+ if [[ "${SYSFS}" == 'btrfs' ]]; then
+ wipefs "$2"
+ if _remake "${SYSFS}" "-f -L" "SYSFS" "$2"; then
+ echo "File system created"
+ _ctflag_remake=0
+ else
+ echo "Failed creating new filesystem"
+ _ctflag_remake=1
+ fi
+ else
+ wipefs "$2"
+ if _remake "${SYSFS}" "-F -L" "SYSFS" "$2"; then
+ echo "File system created"
+ _ctflag_remake=0
+ else
+ echo "Failed creating new filesystem"
+ _ctflag_remake=1
+ fi
+ fi
+ else
+ echo "Failed unmounting /mnt/workdir"
+ _ctflag_remake=1
+ fi
+ export _ctflag_remake
+} \ No newline at end of file