From d451b29a8b4a3f3f4d5f2940e0855f73ab39607c Mon Sep 17 00:00:00 2001 From: "Christos.K" Date: Sat, 8 Jul 2017 05:25:02 +0300 Subject: Minor update --- config.d/controller/modules/cfunctions.sh | 41 +++++++++++++++++++++++++- config.d/controller/modules/cinit_pre-mount.sh | 1 - 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/config.d/controller/modules/cfunctions.sh b/config.d/controller/modules/cfunctions.sh index 5ac686a..08d669b 100755 --- a/config.d/controller/modules/cfunctions.sh +++ b/config.d/controller/modules/cfunctions.sh @@ -321,6 +321,9 @@ _fetch_new_sys() { export _sys_archive 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 else @@ -334,6 +337,42 @@ _fetch_new_sys() { fi } +_verify_t() { + _verify_md5sum() { + if md5sum -c "${_sys_archive}.md5sum"; then + return 0 + else + return 1 + fi + } + + _verify_origin() { + ( + cd "$1" + + if gpg --verify "$1/${_sys_archive}.gpg"; then + echo "PASS" > verify.info + else + echo "FAILED" > verify.info + fi + ) + } + + if _verify_origin "$1"; then + echo "Image's integrity verified" + _verify_md5sum "$1" + if [[ "$(cat verify.info)" == 'PASS' ]]; then + echo "Image's authentication verified" + elif [[ "$(cat verify.info)" == 'FAILED' ]]; then + echo "Failed to verify the authentication of the image" + _call_backup_switch + fi + rm -f verify.info + else + echo "Image integrity failed" + fi +} + _extract_sys() { ( cd "$1" @@ -404,4 +443,4 @@ controller_master_loop() { esac done -} \ No newline at end of file +} diff --git a/config.d/controller/modules/cinit_pre-mount.sh b/config.d/controller/modules/cinit_pre-mount.sh index 1c5d393..0937c72 100755 --- a/config.d/controller/modules/cinit_pre-mount.sh +++ b/config.d/controller/modules/cinit_pre-mount.sh @@ -34,4 +34,3 @@ if [[ "${_ctflag_net}" ]]; then # CHROOT SYSTEM AND INITIATE THE CCHROOT.SH _chroot_config "$/mnt/workdir" "var/tmp/ctworkdir/cchroot" fi - -- cgit v1.2.3-65-gdbad