#!/bin/bash set -e [[ -z $1 ]] && echo "usage: ${0##*/} " && exit 1 target=$1 [[ ! -d $target/ ]] && echo $target/ does not exist && exit 1 [[ -z `mount | grep ${target%%/}` ]] && echo partition is not mounted into $target/ && exit 1 [[ ! -f slackstart.conf ]] && echo slackstart.conf missing && exit 1 echo -n sourcing slackstart.conf ... . ./slackstart.conf && echo done [[ -z $mirror ]] && echo define mirror && exit 1 echo -n disabling non-root login ... echo non-root login has been disabled > lala/etc/nologin && echo done echo -n locale and bash aliases in /etc/shrc ... if [[ -f lala/etc/shrc ]]; then echo already else # beware escapes are in there - $ - ` - $NF 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 ps2='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 #rc.inet2 \ # deal with minimal echo disabling few init scripts for f in rc.cpufreq rc.loop; do chmod -x lala/etc/rc.d/$f done; unset f #rc.modules \ #rc.modules.local \ # full #rc.acpid \ #rc.atd \ #rc.bluetooth \ #rc.fuse \ #rc.fuse3 \ #rc.haveged \ #rc.mcelog \ #rc.wireless \ #[[ -f lala/etc/rc.d/$f ]] && chmod -x lala/etc/rc.d/$f && echo $f init script disabled 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 # trailing-slash already there cat > lala/etc/slackpkg/mirrors < 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 <