#!/bin/bash set -e usage() { cat <<-EOF usage: $0 EOF exit 1 } createfs() { [[ $fs = ext4 ]] && mkfsopts="-F" [[ $fs = xfs ]] && mkfsopts="-f" [[ $fs = reiserfs ]] && mkfsopts="-f" [[ $fs = reiser4 ]] && mkfsopts="-f -y" #[[ $fs = btrfs ]] && mkfsopts="-f" echo creating $guest.$fs dd if=/dev/zero of=$guest.$fs bs=1024k count=0 seek=10240 && echo done targetbd=$guest.$fs echo making $fs file-system on $targetbd: if [[ $fs = jfs ]]; then echo y | mkfs.$fs $targetbd && echo done else mkfs.$fs $mkfsopts $targetbd && echo done fi echo -n mounting $targetbd... mkdir lala/ mount -t $fs -o loop,rw $targetbd lala/ && echo done unset targetbd } [[ -z $3 ]] && usage fs=$1 guest=$2 ip=$3 targettag=ADD [[ ! -x /root/bin/slackware.install.bash ]] && echo /root/bin/slackware.install.bash not executable && exit 1 [[ -d /data/guests/$guest/ ]] && echo /data/guests/$guest/ already exists && exit 1 mkdir /data/guests/$guest/ cd /data/guests/$guest/ /data/tftpboot/sync.slackware createfs mount | grep lala echo '' /root/bin/slackware.install.bash $targettag #[[ ! -f ../lala.tar.gz ]] && echo ../lala.tar.gz not found && exit 1 #echo -n extracting ../lala.tar.gz... #tar xzf ../lala.tar.gz && echo done [[ ! -d lala/etc/ ]] && echo WTF lala/etc/ not found && exit 1 echo -n writing fstab... cat > lala/etc/fstab <<-EOF && echo done /dev/xvda1 / $fs defaults,noatime,nodiratime 1 1 devpts /dev/pts devpts gid=5,mode=620 0 0 proc /proc proc defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 EOF echo disabling useless shit from rc.d tag ADD chmod -x lala/etc/rc.d/rc.cpufreq chmod -x lala/etc/rc.d/rc.loop #chmod -x lala/etc/rc.d/rc.modules #chmod -x lala/etc/rc.d/rc.modules.local echo -n lib.modules... tar xzf /data/kernels/lib.modules.4.18.16.domureiser4.tar.gz -C lala/lib/modules/ && echo done echo -n enabling TMEM... cat >> lala/etc/rc.d/rc.modules.local < lala/etc/rc.d/rc.inet1 < lala/etc/HOSTNAME && echo done mv lala/etc/hosts lala/etc/hosts.dist cat > lala/etc/hosts < lala/etc/resolv.conf < lala/root/.ssh/authorized_keys < lala/etc/inittab && echo done echo -n adding hvc0... cat >> lala/etc/inittab <> lala/etc/securetty && echo done echo fixing timezone rm -f lala/etc/localtime-copied-from rm -f lala/etc/localtime ln -s ../usr/share/zoneinfo/Europe/Moscow lala/etc/localtime #ln -s ../usr/share/zoneinfo/Europe/Paris lala/etc/localtime mv lala/etc/slackpkg/mirrors lala/etc/slackpkg/mirrors.dist echo 'http://10.1.1.12/slackware142/' > lala/etc/slackpkg/mirrors echo '# http://mirror.rol.ru/slackware/slackware64-14.2/' >> lala/etc/slackpkg/mirrors #cp lala/etc/profile lala/etc/profile.dist #echo -n shell aliases... #echo >> lala/etc/profile <> lala/etc/rc.d/rc.modules.local <<-EOF && echo done /sbin/modprobe tmem EOF chmod +x lala/etc/rc.d/rc.modules chmod +x lala/etc/rc.d/rc.modules.local echo -n cpu-online... cat > lala/etc/udev/rules.d/cpu-online.rules <<-EOF && echo done SUBSYSTEM=="cpu", ACTION=="add", RUN+="/bin/sh -c 'echo 1 > %S%p/online'" EOF echo -n setting up openssh... mv lala/etc/ssh/sshd_config lala/etc/ssh/sshd_config.dist sed '/^#/d; /^$/d' lala/etc/ssh/sshd_config.dist > lala/etc/ssh/sshd_config.dist.clean cat > lala/etc/ssh/sshd_config < $guest <