From d288be448905bf2b8e6d88b12d668c7e411540e8 Mon Sep 17 00:00:00 2001 From: "Christos.K" Date: Tue, 22 Aug 2017 13:48:56 +0300 Subject: Newsystem functions --- config.d/controller/modules/functions/ct_newsys.sh | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 config.d/controller/modules/functions/ct_newsys.sh 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 -- cgit v1.2.3-65-gdbad