aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos.K <freedomrfox@gmail.com>2017-08-25 05:36:20 +0300
committerChristos.K <freedomrfox@gmail.com>2017-08-25 05:36:20 +0300
commit42376ca46290d7c608c0c3dd9db40649ca3ee39a (patch)
treecf7536d5d3edc1cca254f5d830cf6e83ccf44340
parentUpdated rescue_shell function echos (diff)
downloadGSE-42376ca46290d7c608c0c3dd9db40649ca3ee39a.tar.gz
GSE-42376ca46290d7c608c0c3dd9db40649ca3ee39a.tar.bz2
GSE-42376ca46290d7c608c0c3dd9db40649ca3ee39a.zip
Included the config function for the chroot phase
-rw-r--r--config.d/controller/modules/functions/ct_config.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/config.d/controller/modules/functions/ct_config.sh b/config.d/controller/modules/functions/ct_config.sh
new file mode 100644
index 0000000..8497fd0
--- /dev/null
+++ b/config.d/controller/modules/functions/ct_config.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+_chroot_config(){
+ _revert_chroot() {
+ if chroot "$1" "$2"; then
+ return 0
+ else
+ return 1
+ fi
+ }
+
+ _init_chroot() {
+ if chroot "$1" "$2"; then
+ echo "Configuration was successful"
+ _sys_config=0
+ else
+ echo "Configuration failed"
+ echo "Reverting changes"
+ if _revert_chroot "$1" "var/tmp/ctworkdir/ccrevert_chroot.sh"; then
+ echo "Changes reverted"
+ else
+ echo "Failed reverting changes"
+ echo "Calling backup system"
+ fi
+ _sys_config=1
+ fi
+ export _sys_config
+ }
+
+ _prep_chroot() {
+ if _mount_sysfs "$1" && mount_pseudo "$1"; then
+ mkdir -p "$1/var/tmp/ctworkdir"
+ cp -r "${CTCONFDIR}/confdir" "$1/var/tmp/ctworkdir/"
+ cp "/usr/local/controller/cchroot.sh" "$1/var/tmp/ctworkdir/cchroot"
+ _init_chroot "$@"
+ else
+ _sys_config=1
+ export _sys_config
+ fi
+ }
+
+ if _unmount "$1"; then
+ _prep_chroot "$@"
+ else
+ _sys_config=1
+ export _sys_config
+ fi
+} \ No newline at end of file