post_boot.sh
I apreciate that you took post_boot.sh on board! Here are a few suggestions on the current implementation:
1 You left all the post-boot tasks in /etc/profile, further a lot of them use sudo.
This is bad for several reasons: a) if no local user logs in after boot, net related fixes wont have run when remote logging is attempted. b) This assumes logged in user has sudo, whilst probably true at this point in time, its an unnecesary dependency, that sooner or later down the line will blow up and cause issues. c) Unless Im mistaken they are post boot one-offs. If that is true no need to have them run on each login.
2 It should probably be in /usr/local/sbin This is kind of my fault, when I first sent it to you I referred to its path as /usr/local/bin out of habit
I will include samples of post_boot.sh and /etc/profile with changes that seem to not cause any issue on my instance, but before using, I would suggest to double check all the changes.
Hm file upload doesn't seem to work on the iPad...
#!/bin/sh
#
# Copyright (c) 2022: [email protected]
# License: MIT
#
# Version: 1.1.0 2022-05-10
#
# Intended usage is for cronless systems, or when cron can not be trusted
# to start up on its own. Needing to do some sanity checks after booting.
# Trigger this in /etc/inittab by adding a line:
#
# ::wait:/usr/local/bin/post_boot.sh
#
# Before starting /sbin/openrc or similar
#
#
# If run with no params, spawn another instance in the background and exit
# in order to be inittab friendly
#
if [ "$1" = "" ]; then
$0 will_run > /tmp/post_boot.log 2>&1 &
exit 0
fi
#
# Give the system time to complete it's startup
#
sleep 10
if [[ -e /etc/FIRSTBOOT ]]; then
# /dev/null gets screwed up at times. Recreate just in case
# the first time we boot
rm /dev/null > /tmp/profile.debug 2>&1
mknod /dev/null c 1 3 >> /tmp/profile.debug 2>&1
chmod 666 /dev/null >> /tmp/profile.debug 2>&1
# Start a couple of services
rc-update add dcron >/dev/null 2>/dev/null
rc-update add runbg >/dev/null 2>/dev/null
rm /etc/FIRSTBOOT # Only do this stuff once, so remove the file now
fi
# The following is needed for upstream PR #1716
if [ ! -e /dev/fd ]; then
ln -s /proc/self/fd /dev/fd
fi
# Hack for Alpine 3.14.0
OS=`/bin/cat /etc/alpine-release`
if [ $OS = '3.14.0' ]; then
# In Alpine 3.14 services do not start up correctly. Run script to fix
# that if needed
/usr/local/bin/fix_services
fi
# /etc/init.d/networking keeps getting an extra } written at the end
# For some unknown reason. Overwrite it when we login to hopefully
# mitigate that
#cp /root/init.d/networking /etc/init.d
#
# Ensure intended services are up
#
/etc/init.d/sshd restart
/etc/init.d/runbg restart
/etc/init.d/dcron restart
#!/bin/bash
# Do various things to make iSH more useful. Or work around
# oddness
# First we do stuff that only needs to happen when the root image
# is booted for the first time
ID=`id -u`
# Hack for Alpine 3.14.0
OS=`/bin/cat /etc/alpine-release`
# motd works for root it 3.14.0, but not anyone else for some reason. Annoying
if [ $OS = '3.14.0' ] && [ $ID -ne 0 ]; then
echo
cat /etc/motd
fi
# Let's set the path here since that covers both zsh and bash
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/games
CHECK=`/bin/rc-status 2> /dev/null | grep sshd | wc -l`
VERBOSE=0
if [ $CHECK -eq 0 ] || [ $ID -ne 0 ]; then
VERBOSE=1
fi
# echo $CHECK $ID $VERBOSE
if [[ $VERBOSE -eq 1 ]]; then
echo
echo "------------------------------------------"
echo
fi
if [[ $CHECK -eq 0 ]]; then
echo "Enable sshd on port 1022: enable_sshd"
echo
fi
if [[ $ID -ne 0 ]]; then
echo "Use sudo to run commands as root"
echo
fi
if [[ $VERBOSE -eq 1 ]]; then
echo "------------------------------------------"
echo
fi
CPU_STATE=`/usr/local/bin/mc status`
echo "Multicore State=$CPU_STATE"
LOCK_STATE=`/usr/local/bin/elock status`
echo "Extra Locking State=$LOCK_STATE"
echo ""
Sorry about that and thank you for the fixes/updates. I'll investigate/incorporate these into the next FS release.