diff options
-rwxr-xr-x[-rw-r--r--] | setup-alpine.in | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/setup-alpine.in b/setup-alpine.in index 0b76d5a..a338549 100644..100755 --- a/setup-alpine.in +++ b/setup-alpine.in @@ -16,15 +16,56 @@ get_fqdn() { echo "${_dn:=my.domain}" } -while getopts "ah" opt ; do +usage() { + cat <<__EOF__ +usage: setup-alpine [-ha] [-f FILE] [-c FILE] + +Setup Alpine Linux + +options: + -h Show this help + -a Create Alpine Linux overlay file + -f Answer file to use installation + -c Create answer file (do not install anything) +__EOF__ + exit 1 +} + +while getopts "af:c:h" opt ; do case $opt in a) ARCHIVE=yes;; + f) USEANSWERFILE="$OPTARG";; + c) CREATEANSWERFILE="$OPTARG";; h) usage;; *) usage;; esac done shift `expr $OPTIND - 1` +if [ "$USEANSWERFILE" != "" ]; then + if [ -e "$USEANSWERFILE" ]; then + . "$USEANSWERFILE" + fi +fi + +if [ "$CREATEANSWERFILE" != "" ]; then + touch "$CREATEANSWERFILE" || echo "Cannot touch file $CREATEANSWERFILE" + cat <<__EOF__ > "$CREATEANSWERFILE" +KEYMAPOPTS="" +HOSTNAMEOPTS="" +INTERFACESOPTS="" +DNSOPTS="" +TIMEZONEOPTS="" +APKREPOSOPTS="" +SSHDOPTS="" +NTPOPTS="" +DISKOPTS="" +APKLBUOPTS="" +__EOF__ + echo "Answer file $CREATEANSWERFILE has been created. Please add or remove options as desired in that file" + exit 0 +fi + if [ "$ARCHIVE" ] ; then echo "Creating an Alpine overlay" init_tmpdir ROOT @@ -32,19 +73,19 @@ else PKGADD=apk_add fi -$PREFIX/sbin/setup-keymap -$PREFIX/sbin/setup-hostname -$PREFIX/sbin/setup-interfaces +$PREFIX/sbin/setup-keymap ${KEYMAPOPTS} +$PREFIX/sbin/setup-hostname ${HOSTNAMEOPTS} +$PREFIX/sbin/setup-interfaces ${INTERFACEOPTS} # setup up dns if no dhcp was configured grep '^iface.*dhcp' $ROOT/etc/network/interfaces > /dev/null ||\ - $PREFIX/sbin/setup-dns + $PREFIX/sbin/setup-dns ${DNSOPTS} # set root password [ -z "$NOCOMMIT" ] && while ! passwd ; do echo "Please retry." ; done # pick timezone -$PREFIX/sbin/setup-timezone +$PREFIX/sbin/setup-timezone ${TIMEZONEOPTS} rc-update -q add networking boot rc-update -q add urandom boot @@ -71,15 +112,15 @@ _hn=${_hn%%.*} sed -i -e "s/^127\.0\.0\.1.*/127.0.0.1\t${_hn}.${_dn:-$(get_fqdn)} ${_hn} localhost.localdomain localhost/" /etc/hosts -$PREFIX/sbin/setup-apkrepos +$PREFIX/sbin/setup-apkrepos ${APKREPOSOPTS} -$PREFIX/sbin/setup-sshd +$PREFIX/sbin/setup-sshd ${SSHDOPTS} -$PREFIX/sbin/setup-ntp +$PREFIX/sbin/setup-ntp ${NTPOPTS} DEFAULT_DISK=none \ - $PREFIX/sbin/setup-disk -q + $PREFIX/sbin/setup-disk -q ${DISKOPTS} if ![ "`cat /tmp/alpine-install-diskmode.out`" = "sys" ]; then - $PREFIX/sbin/setup-apklbu -i + $PREFIX/sbin/setup-apklbu -i ${APKLBUOPTS} fi |