aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos.K <freedomrfox@gmail.com>2017-07-11 16:46:48 +0300
committerChristos.K <freedomrfox@gmail.com>2017-07-11 16:46:48 +0300
commit451fd8d92ab15a395328dcf4be1eb0c7d612c253 (patch)
tree7e7a2f7e0b7b8ba0c9f82d0306316cdfc5b9ecb7
parentRemoved testing entries (diff)
downloadGSE-451fd8d92ab15a395328dcf4be1eb0c7d612c253.tar.gz
GSE-451fd8d92ab15a395328dcf4be1eb0c7d612c253.tar.bz2
GSE-451fd8d92ab15a395328dcf4be1eb0c7d612c253.zip
Updated pre-mount functions
-rw-r--r--config.d/controller/modules/cfunctions.sh35
-rwxr-xr-xconfig.d/controller/modules/cinit_pre-mount.sh48
-rw-r--r--config.d/controller/modules/cnetwork.sh31
3 files changed, 86 insertions, 28 deletions
diff --git a/config.d/controller/modules/cfunctions.sh b/config.d/controller/modules/cfunctions.sh
index c089fee..55e0363 100644
--- a/config.d/controller/modules/cfunctions.sh
+++ b/config.d/controller/modules/cfunctions.sh
@@ -58,7 +58,7 @@ _bsu_dfs() {
fi
}
-server_exp() {
+_server_exp() {
echo "Selecting server..."
_ser_list=()
while read -r "s";do
@@ -181,14 +181,14 @@ _check_version() {
else
_ctflag_sysfetch=1
fi
- export _ctflag_sysfetch
else
_ctflag_sysfetch=0
- export _ctflag_sysfetch
fi
else
echo "Remote version matches the local"
+ _ctflag_sysfetch=1
fi
+ export _ctflag_sysfetch
}
mv_pseudo() { # ${rsys}
@@ -263,7 +263,7 @@ _chroot_config(){
fi
_sys_config=1
fi
- export _no_config
+ export _sys_config
}
_prep_chroot() {
@@ -296,22 +296,25 @@ _remake_sysfs() {
if [[ "${SYSFS}" == 'btrfs' ]]; then
if eval "mkfs.${SYSFS}" -L ROOTFS -f "${SYSDEV}"; then
echo "File system created"
+ _ctflag_remake=0
else
echo "Failed creating new filesystem"
- _call_backup_switch
+ _ctflag_remake=1
fi
else
if eval "mkfs.${SYSFS}" -L ROOTFS "${SYSDEV}"; then
echo "File system created"
+ _ctflag_remake=0
else
echo "Failed creating new filesystem"
- _call_backup_switch
+ _ctflag_remake=1
fi
fi
else
echo "Failed unmounting workdir"
- _call_backup_switch
+ _ctflag_remake=1
fi
+ export _ctflag_remake
}
_fetch_new_sys() {
@@ -322,18 +325,17 @@ _fetch_new_sys() {
if sync -aAXhq "${_act_user}@${_act_ser}/${_dist_dir}/${_sys_archive}" "$1/"; then
scp "${_act_user}@${_act_ser}/${_dist_dir}/${_sys_archive}.md5sum" "$1/"
scp "${_act_user}@${_act_ser}/${_dist_dir}/${_sys_archive}.gpg" "$1/"
- _verify_t
echo "New system was fetched successfully"
- _ctflag_extract=0
+ _ctflag_fetch=0
else
echo "Fetching new system FAILED"
- _ctflag_extract=1
+ _ctflag_fetch=1
fi
- export _ctflag_extract
else
echo "Failed mounting ${SYSDEV} to $1"
- _call_backup_switch
+ _ctflag_fetch=1
fi
+ export _ctflag_fetch
}
_verify_t() {
@@ -369,17 +371,16 @@ _verify_t() {
_verify_md5sum
if _check_s "$1"; then
echo "Image's integrity is healthy"
- return 0
+ _ctflag_verify=0
else
echo "Image's integrity check failed"
- _call_backup_switch
- return 1
+ _ctflag_verify=1
fi
else
echo "Failed to verify the authentication of the image"
- _call_backup_switch
- return 1
+ _ctflag_verify=1
fi
+ export _ctflag_verify
}
_check_s() {
diff --git a/config.d/controller/modules/cinit_pre-mount.sh b/config.d/controller/modules/cinit_pre-mount.sh
index 7de4e06..a076333 100755
--- a/config.d/controller/modules/cinit_pre-mount.sh
+++ b/config.d/controller/modules/cinit_pre-mount.sh
@@ -18,23 +18,49 @@ source "${CTSCRIPTS}/cfunctions.sh"
source "${CTSCRIPTS}/cnetwork.sh"
# WIPE OLD FS, CREATE NEW FS & FETCH NEW SYSTEM
-if [[ "${_ctflag_sysfetch}" == 0 && -n "${_ctflag_net}" ]]; then
+if [[ "${_ctflag_sysfetch}" == 0 && "${_ctflag_net}" == 0 ]]; then
# WIPE & CREATE NEW FS
_remake_sysfs "/mnt/workdir"
+
# FETCH NEW SYSTEM
- _fetch_new_sys "/mnt/workdir"
+ if [[ "${_ctflag_remake}" == 0 ]]; then
+ _fetch_new_sys "/mnt/workdir"
+ elif [[ "${_ctflag_remake}" == 1 ]]; then
+ _call_backup_switch
+ fi
+
# VERIFY FETCHED IMAGE
- _verify_t "/mnt/workdir"
+ if [[ "${_ctflag_fetch}" == 0 ]]; then
+ _verify_t "/mnt/workdir"
+ elif [[ "${_ctflag_fetch}" == 1 ]]; then
+ _call_backup_switch
+ fi
+
# EXTRACT NEW SYSTEM
- _extract_sys "/mnt/workdir"
- rm -f "/mnt/workdir/verify.info"
- _check_s "/mnt/workdir"
+ 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
+ fi
+ export _ctflag_extract
+ elif [[ "${_ctflag_verify}" == 1 ]]; then
+ _call_backup_switch
+ fi
fi
# CONFIGURATION
-if [[ "${_ctflag_net}" ]]; then
+if [[ "${_ctflag_net}" == 0 ]] && [[ "${_ctflag_confd}" == 0 || "${_ctflag_extract}" == 0 ]]; then
# MOUNT SYSTEM
- _mount_sysfs "/mnt/workdir"
- # CHROOT SYSTEM AND INITIATE THE CCHROOT.SH
- _chroot_config "$/mnt/workdir" "var/tmp/ctworkdir/cchroot"
-fi
+ if _mount_sysfs "/mnt/workdir"; then
+ # CHROOT SYSTEM AND INITIATE THE CCHROOT.SH
+ _chroot_config "$/mnt/workdir" "var/tmp/ctworkdir/cchroot"
+ if [[ "{_ctflag_extract}" == 0 && "${_sys_config}" == 1 ]]; then
+ _call_backup_switch
+ fi
+ else
+ echo "Could not mout sysfs @ /mnt/workdir"
+ fi
+fi \ No newline at end of file
diff --git a/config.d/controller/modules/cnetwork.sh b/config.d/controller/modules/cnetwork.sh
new file mode 100644
index 0000000..0942043
--- /dev/null
+++ b/config.d/controller/modules/cnetwork.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# SIMPLE DHCP NETWORKING
+if _call_net; then
+ _ctflag_net=0
+ export _ctflag_net
+else
+ _ctflag_net=1
+ export _ctflag_net
+fi
+
+# CHECK NETWORK FLAG AND FETCH VERSION AND CONFIG.D DIRECTORY
+if [[ "${_ctflag_net}" == 0 ]]; then
+ # DEFINE BEST ACTIVE SERVER
+ _server_exp
+
+ # EXPORT VARIABLES FROM SOURCES CONFIG FILE
+ _sources_exp
+
+ # FETCH CONFIG.D
+ _fetch_confd
+ if [[ "${_ctflag_confd}" == 0 ]]; then
+ # EXPORT NEW CONFIGS
+ _bsu_dfs
+ fi
+
+ # MOUNT SYSFS AS RO
+ _mount_sysfs "/mnt/workdir"
+ # CHECK LOCAL VERSION OF SYSFS WITH SERVERS VERSION
+ _check_version
+fi \ No newline at end of file