aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos.K <freedomrfox@gmail.com>2017-07-06 22:32:30 +0300
committerChristos.K <freedomrfox@gmail.com>2017-07-06 22:32:30 +0300
commitfc7c4022e6b4a755a0e932b893bb1d121ad49a78 (patch)
tree0bdf1bb4acb3a21375603133aaf7037c034ade5a
parentMinor changes (diff)
downloadGSE-fc7c4022e6b4a755a0e932b893bb1d121ad49a78.tar.gz
GSE-fc7c4022e6b4a755a0e932b893bb1d121ad49a78.tar.bz2
GSE-fc7c4022e6b4a755a0e932b893bb1d121ad49a78.zip
Updated cfunctions and module-setup
-rw-r--r--config.d/controller/modules/cfunctions.sh79
-rwxr-xr-xconfig.d/controller/modules/module-setup.sh2
-rw-r--r--config.d/system/gentoo.conf12
3 files changed, 92 insertions, 1 deletions
diff --git a/config.d/controller/modules/cfunctions.sh b/config.d/controller/modules/cfunctions.sh
index ae50300..6b30215 100644
--- a/config.d/controller/modules/cfunctions.sh
+++ b/config.d/controller/modules/cfunctions.sh
@@ -184,6 +184,85 @@ _check_version() {
fi
}
+mv_pseudo() { # ${rsys}
+ # Moving sys proc dev to rfs
+ echo "Moving sys proc dev to rfs"
+ for i in sys proc dev
+ do
+ echo "Moved ${i} to $1/${i}"
+ mount --move "$2/${i}" "$1/${i}"
+ done
+}
+
+mount_pseudo() {
+ mount -t proc /proc "$1/proc" || return 1
+ mount --rbind /dev "$1/dev" || return 1
+ mount --rbind /sys "$1/sys" || return 1
+ mount --make-rslave "$1/dev" || return 1
+ mount --make-rslave "$1/sys" || return 1
+}
+
+umount_pseudo() {
+ umount -l "$1/proc" >/dev/null 2>&1
+ umount -l "$1/dev" >/dev/null 2>&1
+ umount -l "$1/sys" >/dev/null 2>&1
+ umount -l "$1"/* >/dev/null 2>&1
+}
+
+_unmount() {
+ k=0
+ if [[ -n "$(grep "mnt/$2" "/proc/mounts" | awk -F ' ' '{ print $2 }')" ]]; then
+ while true; do
+ while read -r i; do
+ eval umount -l "$i"/* >/dev/null 2>&1
+ eval umount -l "$i" >/dev/null 2>&1
+ done < <(grep "/mnt/$2" "/proc/mounts" | awk -F ' ' '{ print $2 }')
+
+ if [[ -z $(grep "/mnt/$2" "/proc/mounts" | awk -F ' ' '{ print $2 }') ]]; then
+ break
+ fi
+
+ [[ "$k" -ge 20 ]] && return 1
+ ((++k))
+ done
+ return 0
+ fi
+}
+
+_chroot_config(){
+ if _unmount "$1" "$2"; then
+ if 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"
+
+ if chroot "$1" "var/tmp/ctworkdir/cchroot"; then
+ echo "Configuration was successful"
+ else
+ echo "Configuration failed"
+ echo "Reverting changes"
+ if _revert_chroot; then
+ echo "Changes reverted"
+ else
+ echo "Failed reverting changes"
+ echo "Calling backup system"
+ fi
+ fi
+ else
+ echo "Failed mounting pseudo filesystems"
+ echo "Configuration can not proceed"
+ _flag_config_check=1
+ export _flag_config_check
+ echo "Proceeding"
+ fi
+ else
+ echo "Something went wrong"
+ echo "Proceeding without configuration"
+ _flag_config_check=1
+ export _flag_config_check
+ fi
+}
+
_remake_sysfs() {
if umount "/mnt/workdir"; then
if [[ "${SYSFS}" == 'btrfs' ]]; then
diff --git a/config.d/controller/modules/module-setup.sh b/config.d/controller/modules/module-setup.sh
index 98eba63..7966d7e 100755
--- a/config.d/controller/modules/module-setup.sh
+++ b/config.d/controller/modules/module-setup.sh
@@ -20,7 +20,7 @@ install() {
cp mv busybox rsync ssh gpg bash rmmod dmesg modprobe findmnt \
tar bzip2 ping clear mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.btrfs mkfs.vfat \
e2label mlabel swaplabel scp md5sum sha512sum lsblk tee sed awk arping \
- dhclient ifconfig
+ dhclient ifconfig scp
inst_simple "/lib64/libnss_dns.so.2"
inst_simple "/lib64/libnss_files.so.2"
diff --git a/config.d/system/gentoo.conf b/config.d/system/gentoo.conf
new file mode 100644
index 0000000..c53ff63
--- /dev/null
+++ b/config.d/system/gentoo.conf
@@ -0,0 +1,12 @@
+[DEFAULT]
+main-repo = gentoo
+
+[gentoo]
+location = /usr/portage
+sync-type = rsync
+sync-uri = rsync://192.168.2.2:/usr/portage
+auto-sync = yes
+
+# for daily squashfs snapshots
+#sync-type = squashdelta
+#sync-uri = mirror://gentoo/../snapshots/squashfs