aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos.K <freedomrfox@gmail.com>2017-08-22 13:53:13 +0300
committerChristos.K <freedomrfox@gmail.com>2017-08-22 13:53:13 +0300
commit5f0e9822021d86ca1b36d003fc44a727b31026b0 (patch)
tree68b3b190a263f4ef5ef31f2826bed38eb04dc930
parentincluded extra dev entries (diff)
downloadGSE-5f0e9822021d86ca1b36d003fc44a727b31026b0.tar.gz
GSE-5f0e9822021d86ca1b36d003fc44a727b31026b0.tar.bz2
GSE-5f0e9822021d86ca1b36d003fc44a727b31026b0.zip
Major cinit_pre-mount.sh fixes
-rwxr-xr-xconfig.d/controller/modules/cinit_pre-mount.sh98
1 files changed, 67 insertions, 31 deletions
diff --git a/config.d/controller/modules/cinit_pre-mount.sh b/config.d/controller/modules/cinit_pre-mount.sh
index 61fe6b2..c3289b8 100755
--- a/config.d/controller/modules/cinit_pre-mount.sh
+++ b/config.d/controller/modules/cinit_pre-mount.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+# This is the first controller's script.
+# The script is sourced at pre-mount hook points, after udev has finished with a priority of 08.
+
# EXPORT CONTROLLER CONFDIR
CTCONFDIR=/config.d
export CTCONFDIR
@@ -12,48 +15,81 @@ export CTSCRIPTS
export "PATH=${PATH}:/usr/local/controller"
# CONTROLLER FUNCTIONS
-source "${CTSCRIPTS}/cfunctions.sh"
+source "${CTSCRIPTS}/ct_prelim.sh"
+
+_a_priori_devices
# NETWORK SCRIPT
source "${CTSCRIPTS}/cnetwork.sh"
-# IMPORT GPG PUB KEY
-_gpg_import
+# CHECK NETWORK FLAG AND FETCH VERSION AND CONFIG.D DIRECTORY
+if [[ "${_ctflag_net}" == 0 ]]; then
+ source "${CTSCRIPTS}/ct_fetch.sh"
-# WIPE OLD FS, CREATE NEW FS & FETCH NEW SYSTEM
-if [[ "${_ctflag_sysfetch}" == 0 && "${_ctflag_net}" == 0 ]]; then
- # WIPE & CREATE NEW FS
- _remake_sysfs "/mnt/workdir"
-
- # FETCH NEW SYSTEM
- if [[ "${_ctflag_remake}" == 0 ]]; then
- _fetch_new_sys "/mnt/workdir"
- elif [[ "${_ctflag_remake}" == 1 ]]; then
- _call_backup_switch
- fi
+ # EXPORT SERVER'S INFO
+ _sources_exp
- # VERIFY FETCHED IMAGE
- if [[ "${_ctflag_fetch}" == 0 ]]; then
- _verify_t "/mnt/workdir"
- elif [[ "${_ctflag_fetch}" == 1 ]]; then
- _call_backup_switch
- fi
+ # MOUNT SYSFS AS RW
+ _mount_sysfs "/mnt/workdir"
+
+ # FETCH CONFIG.D
+ _fetch_confd
+
+ # FETCH LATEST VERSION
+ _fetch_version
- # EXTRACT NEW SYSTEM
- if [[ "${_ctflag_verify}" == 0 ]]; then
- _extract_sys "/mnt/workdir"
- rm -f "/mnt/workdir/verify.info"
- if _check_s "/mnt/workdir"; then
- _ctflag_extract=0
- else
- _ctflag_extract=1
+ # MOUNT SYSFS AS RW
+ _mount_sysfs "/mnt/workdir"
+ # CHECK LOCAL VERSION OF SYSFS WITH SERVERS VERSION
+ _check_version
+
+ # IMPORT GPG PUB KEY
+ # _gpg_import
+
+ source "${CTSCRIPTS}/ct_newsys.sh"
+ _bsu_dfs
+
+ # WIPE OLD FS, CREATE NEW FS & FETCH NEW SYSTEM
+ if [[ "${_ctflag_switch}" != '0' ]]; then
+ if [[ "${_ctflag_sysfetch}" == 0 && "${_ctflag_net}" == 0 ]]; then
+ # WIPE & CREATE NEW FS
+ _remake_dev "/mnt/workdir" "${SYSDEV}"
+
+ # FETCH NEW SYSTEM
+ if [[ "${_ctflag_remake}" == 0 ]]; then
+ _fetch_new_sys "/mnt/workdir"
+ elif [[ "${_ctflag_remake}" == 1 ]]; then
+ _call_backup_switch
+ fi
+
+ # VERIFY FETCHED IMAGE
+ if [[ "${_ctflag_fetch}" == 0 ]]; then
+ _verify_target "/mnt/workdir"
+ elif [[ "${_ctflag_fetch}" == 1 ]]; then
+ _call_backup_switch
+ fi
+
+ # EXTRACT NEW SYSTEM
+ if [[ "${_ctflag_verify}" == 0 ]]; then
+ _extract_sys "/mnt/workdir" "${_sys_archive}"
+ rm -f "/mnt/workdir/verify.info"
+ if _check_last "/mnt/workdir"; then
+ _ctflag_extract=0
+ else
+ _ctflag_extract=1
+ fi
+ export _ctflag_extract
+ elif [[ "${_ctflag_verify}" == 1 ]]; then
+ _call_backup_switch
+ fi
fi
- export _ctflag_extract
- elif [[ "${_ctflag_verify}" == 1 ]]; then
- _call_backup_switch
fi
fi
+if [[ "${_ctflag_switch}" == 0 ]]; then
+
+
+return 1
# CONFIGURATION
if [[ "${_ctflag_net}" == 0 ]] && [[ "${_ctflag_confd}" == 0 || "${_ctflag_extract}" == 0 ]]; then
# MOUNT SYSTEM