#!/bin/bash # stops it case there is an fsck fix for re-creating lost+found #set -e # guest specific sysprep script (removing kernel) # this script works against CURRENT and for a minimal ADD setup # it is supposed to be one-shot, does handle .dist other than the -i trick [[ -z $3 ]] && echo usage: $0 GUEST-NAME MIRROR BOOTSTRAP-FOLDER && exit 1 guest=$1 mirror=$2 bootstrapfolder=$3 [[ ! -d $bootstrapfolder/ ]] && echo $bootstrapfolder/ does not exist && exit 1 [[ -z `mount | grep ${bootstrapfolder%%/}` ]] && echo partition is not mounted into $bootstrapfolder/ && exit 1 # defines zone vpartition fs serial [[ ! -f /root/slackpost.conf ]] && echo /root/slackpost.conf missing && exit 1 echo -n sourcing /root/slackpost.conf ... source /root/slackpost.conf && echo done if [[ $fs = ext4 ]]; then addopts="" elif [[ $fs = reiser4 ]]; then addopts=txmod=wa,discard elif [[ $fs = btrfs ]]; then addopts=compress=lzo elif [[ $fs = f2fs ]]; then addopts=compress_algorithm=lz4,compress_chksum,atgc,gc_merge,lazytime else echo file-system $fs not supported exit 1 fi #[[ ! -f /data/kernels/vmlinuz.5.2.21.lightUreiser4 ]] && \ # echo need /data/kernels/vmlinuz.5.2.21.lightUreiser4 && exit 1 #[[ ! -f /data/kernels/5.2.21.lightUreiser4.tar.gz ]] && \ # echo need /data/kernels/5.2.21.lightUreiser4.tar.gz && exit 1 #echo -n extracting modules... #rm -rf lala/lib/modules/* #should be clean already #ls -lF lala/lib/modules/ #indeed it even deleted the folder. #mkdir -p lala/lib/modules/ #tar xzf /data/kernels/5.2.21.lightUreiser4.tar.gz -C lala/lib/modules/ && echo done #echo -n enabling tmem... #echo /sbin/modprobe tmem >> lala/etc/rc.d/rc.modules.local && echo done #echo -n xen guest config INTO /data2/ ... #cat > $guest < lala/etc/fstab < lala/etc/nologin && echo done echo -n locale and bash aliases in /etc/shrc ... if [[ -f lala/etc/shrc ]]; then echo already else # ESCAPES IN THERE AND NOT ONLY FOR DOLLARS... cat > lala/etc/shrc <<-EOF && echo done export PATH=\$PATH:/etc/rc.d export MAKEFLAGS=-j\$((\`grep ^processor /proc/cpuinfo | tail -1 | awk '{print \$NF}'\` + 1)) export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 export LANGUAGE=en_US:en alias ll='ls --color=auto --group-directories-first -alh' alias ls='ls --color=auto --group-directories-first' alias psu='ps --pid 2 --ppid 2 --deselect ufw' alias cp='cp -i' alias mv='mv -i' alias rm='rm -i' EOF fi echo -n enabling shrc in /etc/profile ... if [[ -f lala/etc/profile.dist ]]; then echo already else cp -p /etc/profile /etc/profile.dist echo source /etc/shrc >> lala/etc/profile && echo done fi # self-verbose chroot lala/ bash -ic update-ca-certificates # deal with minimal (cpufreq) and full echo disabling few init scripts: for f in \ rc.acpid \ rc.atd \ rc.bluetooth \ rc.cpufreq \ rc.fuse \ rc.fuse3 \ rc.haveged \ rc.inet2 \ rc.loop \ rc.mcelog \ rc.wireless \ ; do [[ -f lala/etc/rc.d/$f ]] && chmod -x lala/etc/rc.d/$f && echo $f init script disabled done; unset f #rc.modules \ #rc.modules.local \ echo -n enabling login prompt on $serial ... if [[ -f lala/etc/inittab.dist ]]; then echo already else mv lala/etc/inittab lala/etc/inittab.dist sed -e ' /^#/d; /^$/d; /ctrlaltdel/d; /^c[[:digit:]]:/d; ' lala/etc/inittab.dist > lala/etc/inittab echo "s1:12345:respawn:/sbin/agetty --noclear --local-line $serial 115200 linux" >> lala/etc/inittab echo $serial >> lala/etc/securetty && echo done fi echo -n setting up timezone for $zone ... rm -f lala/etc/localtime-copied-from lala/etc/localtime ln -s ../usr/share/zoneinfo/$zone lala/etc/localtime && echo done echo -n disabling setterm ... chmod -x lala/etc/rc.d/rc.setterm && echo done echo -n setting up slackpkg ... if [[ -f lala/etc/slackpkg/mirrors.dist ]]; then echo already else mv -i lala/etc/slackpkg/mirrors lala/etc/slackpkg/mirrors.dist cat > lala/etc/slackpkg/mirrors <<-EOF && echo done $mirror EOF fi echo -n setting up ssh daemon ... if [[ -f lala/etc/ssh/sshd_config.dist ]]; then echo already done else mv lala/etc/ssh/sshd_config lala/etc/ssh/sshd_config.dist grep -vE '^#|^$' lala/etc/ssh/sshd_config.dist > lala/etc/ssh/sshd_config.clean sed -r 's/^UsePAM.*/usepam no/' lala/etc/ssh/sshd_config.clean > lala/etc/ssh/sshd_config && echo done || echo FAIL echo 'hostkey /etc/ssh/ssh_host_ed25519_key' >> lala/etc/ssh/sshd_config fi # we want a clean config file and trust the right host key upon first connection echo -n handy log viewer ... cat > lala/root/log < lala/etc/rc.d/rc.local_shutdown <