54 lines
1.3 KiB
Bash
Executable file
54 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
_step_counter=0
|
|
step() {
|
|
_step_counter=$(( _step_counter + 1 ))
|
|
printf '\n\033[1;36m%d) %s\033[0m\n' $_step_counter "$@" >&2 # bold cyan
|
|
}
|
|
|
|
sed -Ei "s|^[# ]*(ttyS0:.*)|\1|" /etc/inittab
|
|
|
|
step 'Set up timezone'
|
|
setup-timezone -z UTC
|
|
|
|
step 'Set up hostname'
|
|
cat > /etc/hosts <<-EOF
|
|
127.0.0.1 ${HOSTNAME:-alpine} ${HOSTNAME:-alpine}.local localhost
|
|
::1 ${HOSTNAME:-alpine} ${HOSTNAME:-alpine}.local localhost
|
|
EOF
|
|
echo "${HOSTNAME:-alpine}" > /etc/hostname
|
|
|
|
step 'Set up networking'
|
|
cat > /etc/network/interfaces <<-EOF
|
|
iface lo inet loopback
|
|
iface eth0 inet dhcp
|
|
EOF
|
|
ln -s networking /etc/init.d/net.lo
|
|
ln -s networking /etc/init.d/net.eth0
|
|
|
|
step 'Adjust rc.conf'
|
|
sed -Ei \
|
|
-e 's/^[# ](rc_depend_strict)=.*/\1=NO/' \
|
|
-e 's/^[# ](rc_logger)=.*/\1=YES/' \
|
|
-e 's/^[# ](unicode)=.*/\1=YES/' \
|
|
/etc/rc.conf
|
|
|
|
step 'Enable services'
|
|
rc-update add acpid default
|
|
rc-update add crond default
|
|
rc-update add net.eth0 default
|
|
rc-update add net.lo boot
|
|
rc-update add termencoding boot
|
|
rc-update add sshd default
|
|
|
|
step 'Creating authorized_keys for root'
|
|
mkdir -p /root/.ssh/
|
|
echo "$SSHPUBKEY" >> /root/.ssh/authorized_keys
|
|
|
|
# without this, the system will fail to boot on the next
|
|
# initramfs rebuild
|
|
if [ "$ROOTFS" = 'btrfs' ]; then
|
|
step 'Disabling compression on /boot'
|
|
btrfs property set /boot compression ""
|
|
fi
|
|
|