#!/bin/bash set -e #reiser4 wo compression mkfs -o create=reg40 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=/dev/sdb echo wiping 1024k on $targetbd... dd if=/dev/zero of=$targetbd bs=1024k count=1 && echo done 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/ 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 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 if [[ $targettag = REC || $targettag = OPT ]]; then echo disabling useless shit from rc.d -- tag REC chmod -x lala/etc/rc.d/rc.bluetooth chmod -x lala/etc/rc.d/rc.cgmanager chmod -x lala/etc/rc.d/rc.cgproxy chmod -x lala/etc/rc.d/rc.inetd fi echo -n brutal network setup... mv -i lala/etc/rc.d/rc.inet1 lala/etc/rc.d/rc.inet1.dist chmod -x lala/etc/rc.d/rc.inet1.dist cat > lala/etc/rc.d/rc.inet1 <<-EOF && echo done #!/bin/bash echo rc.inet1 PATH is \$PATH echo -n lo... ifconfig lo up && echo done echo -n eth1... ifconfig eth1 $ip/24 up && echo done echo -n default route... route add default gw ${ip%\.*}.254 && echo done EOF chmod +x lala/etc/rc.d/rc.inet1 echo -n hostname... echo $guest > lala/etc/HOSTNAME && echo done mv lala/etc/hosts lala/etc/hosts.dist cat > lala/etc/hosts <<-EOF 127.0.0.1 localhost $ip $guest ${ip%\.*}.254 snegw #188.130.155.33 gw33 EOF echo -n resolv.conf... cat > lala/etc/resolv.conf <<-EOF && echo done search sne.lan nameserver 10.1.1.5 nameserver 208.67.222.222 nameserver 208.67.220.220 EOF echo -n authorized keys... mkdir lala/root/.ssh/ chmod 700 lala/root/.ssh/ cat > lala/root/.ssh/authorized_keys < lala/etc/inittab && echo done echo -n adding hvc0... cat >> lala/etc/inittab <<-EOF && echo done c1:12345:respawn:/sbin/agetty --noclear 115200,38400,9600 hvc0 linux EOF echo -n securetty... echo hvc0 >> 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 < $guest <