diff options
author | makefu <github@syntax-fehler.de> | 2015-09-23 11:57:27 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2015-09-23 11:57:27 +0200 |
commit | b88363ce1a4ecc420f2c7684c9c74949cd2b5db4 (patch) | |
tree | 2da33dd2e421d498b3172e46234242e1c76370a1 /krebs/4lib/infest/1prepare | |
parent | bb0ec5e74b6ca0737bc49408f00f8918710872a6 (diff) | |
parent | e3222a7e7096d155da507ef41bbb2002ff4aed89 (diff) |
Merge remote-tracking branch 'cloudkrebs/master' into pre-merge
Diffstat (limited to 'krebs/4lib/infest/1prepare')
-rw-r--r-- | krebs/4lib/infest/1prepare | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/krebs/4lib/infest/1prepare b/krebs/4lib/infest/1prepare new file mode 100644 index 000000000..07c00c3a5 --- /dev/null +++ b/krebs/4lib/infest/1prepare @@ -0,0 +1,74 @@ +#! /bin/sh +set -efu + +prepare() {( + if test -e /etc/os-release; then + . /etc/os-release + case $ID in + centos) + case $VERSION_ID in + 7) + prepare_centos7 "$@" + exit + ;; + esac + ;; + esac + fi + echo "$0 prepare: unknown OS" >&2 + exit -1 +)} + +prepare_centos7() { + type bzip2 2>/dev/null || yum install -y bzip2 + type git 2>/dev/null || yum install -y git + type rsync 2>/dev/null || yum install -y rsync + if ! getent group nixbld >/dev/null; then + groupadd -g 30000 -r nixbld + fi + for i in `seq 1 10`; do + if ! getent passwd nixbld$i 2>/dev/null; then + useradd \ + -c "CentOS Nix build user $i" \ + -d /var/empty \ + -g 30000 \ + -G 30000 \ + -l \ + -M \ + -s /sbin/nologin \ + -u $(expr 30000 + $i) \ + nixbld$i + rm -f /var/spool/mail/nixbld$i + fi + done + + # + # mount install directory + # + + if ! mount | grep -Fq '/dev/mapper/centos-root on /mnt type xfs'; then + mkdir -p /newshit + mount --bind /newshit /mnt + fi + + if ! mount | grep -Fq '/dev/sda1 on /mnt/boot type xfs'; then + mkdir -p /mnt/boot + mount /dev/sda1 /mnt/boot + fi + + mount | grep 'on /mnt\>' >&2 + + # + # prepare install directory + # + + mkdir -p /mnt/etc/nixos + mkdir -m 0555 -p /mnt/var/empty + + if ! mount | grep -Fq '/dev/mapper/centos-root on /mnt/root type xfs'; then + mkdir -p /mnt/root + mount --bind /root /mnt/root + fi +} + +prepare "$@" |