main/postmarketos-base: fix wpa_supplicant config (!365)
Fix wifi on htc-ace by properly setting nl80211 before wext.
/etc/conf.d/wpa_supplicant is supposed to get modified twice with the
current code in the post-install file. The first one was patched
recently to set nl80211 before wext, but that change does not work in
practice, for two reasons:
1. The code block does not even get executed, because apk reports that
/etc/conf.d/wpa_supplicant was already modified (by a package that
was installed before, in its post-install script? I could not find
out which one does that though).
2. Even if it worked, the second code block would revert the change and
put wext before nl80211 again.
Fix this by removing the first code block, and changing the order in the
second one. Make it easier to catch such errors in the future, by
printing, which files get modified, or get skipped. Set "#!/bin/sh -e",
so the script can not fail silently.
When doing pmbootstrap -y zap and then pmbootstrap install, the output
looks like this:
(141/151) Installing postmarketos-base (3-r26)
Executing postmarketos-base-3-r26.post-install
- Modifying: /etc/fstab
- Modifying: /etc/issue
- Modifying: /etc/motd
- Modifying: /etc/conf.d/syslog
- Modifying: /etc/conf.d/wpa_supplicant
- Modifying: /etc/sudoers
- Modifying: /etc/chrony/chrony.conf
2019-05-14 19:00:15 +00:00
|
|
|
#!/bin/sh -e
|
2017-05-26 20:26:25 +00:00
|
|
|
|
2017-09-29 16:10:09 +00:00
|
|
|
# Enable udev OpenRC services and runlevels
|
|
|
|
# https://github.com/alpinelinux/aports/blob/master/main/eudev/setup-udev
|
|
|
|
setup-udev -n
|
|
|
|
|
|
|
|
# Enable other OpenRC services
|
2018-12-24 20:45:58 +00:00
|
|
|
for service in devfs dmesg devmappings; do
|
2017-05-26 20:26:25 +00:00
|
|
|
rc-update -q add $service sysinit
|
|
|
|
done
|
2020-04-19 11:45:40 +00:00
|
|
|
for service in hwclock modules sysctl hostname bootmisc syslog; do
|
2017-05-26 20:26:25 +00:00
|
|
|
rc-update -q add $service boot
|
|
|
|
done
|
2018-03-05 21:18:13 +00:00
|
|
|
for service in dbus haveged sshd swapfile wpa_supplicant chronyd local networkmanager; do
|
2017-05-26 20:26:25 +00:00
|
|
|
rc-update -q add $service default
|
|
|
|
done
|
|
|
|
for service in mount-ro killprocs savecache; do
|
|
|
|
rc-update -q add $service shutdown
|
|
|
|
done
|
|
|
|
|
main/postmarketos-base: fix wpa_supplicant config (!365)
Fix wifi on htc-ace by properly setting nl80211 before wext.
/etc/conf.d/wpa_supplicant is supposed to get modified twice with the
current code in the post-install file. The first one was patched
recently to set nl80211 before wext, but that change does not work in
practice, for two reasons:
1. The code block does not even get executed, because apk reports that
/etc/conf.d/wpa_supplicant was already modified (by a package that
was installed before, in its post-install script? I could not find
out which one does that though).
2. Even if it worked, the second code block would revert the change and
put wext before nl80211 again.
Fix this by removing the first code block, and changing the order in the
second one. Make it easier to catch such errors in the future, by
printing, which files get modified, or get skipped. Set "#!/bin/sh -e",
so the script can not fail silently.
When doing pmbootstrap -y zap and then pmbootstrap install, the output
looks like this:
(141/151) Installing postmarketos-base (3-r26)
Executing postmarketos-base-3-r26.post-install
- Modifying: /etc/fstab
- Modifying: /etc/issue
- Modifying: /etc/motd
- Modifying: /etc/conf.d/syslog
- Modifying: /etc/conf.d/wpa_supplicant
- Modifying: /etc/sudoers
- Modifying: /etc/chrony/chrony.conf
2019-05-14 19:00:15 +00:00
|
|
|
# Replace a config file from stock Alpine, unless apk reports that the user has
|
|
|
|
# modified it (note that this does not allow properly updating these configs
|
|
|
|
# when postmarketos-base gets updated yet, see issue pmaports#258).
|
2017-09-30 21:52:33 +00:00
|
|
|
write_unless_modified() {
|
|
|
|
# Redirect the stdin to the file unless it has been modified
|
|
|
|
# $1: file path
|
main/postmarketos-base: fix wpa_supplicant config (!365)
Fix wifi on htc-ace by properly setting nl80211 before wext.
/etc/conf.d/wpa_supplicant is supposed to get modified twice with the
current code in the post-install file. The first one was patched
recently to set nl80211 before wext, but that change does not work in
practice, for two reasons:
1. The code block does not even get executed, because apk reports that
/etc/conf.d/wpa_supplicant was already modified (by a package that
was installed before, in its post-install script? I could not find
out which one does that though).
2. Even if it worked, the second code block would revert the change and
put wext before nl80211 again.
Fix this by removing the first code block, and changing the order in the
second one. Make it easier to catch such errors in the future, by
printing, which files get modified, or get skipped. Set "#!/bin/sh -e",
so the script can not fail silently.
When doing pmbootstrap -y zap and then pmbootstrap install, the output
looks like this:
(141/151) Installing postmarketos-base (3-r26)
Executing postmarketos-base-3-r26.post-install
- Modifying: /etc/fstab
- Modifying: /etc/issue
- Modifying: /etc/motd
- Modifying: /etc/conf.d/syslog
- Modifying: /etc/conf.d/wpa_supplicant
- Modifying: /etc/sudoers
- Modifying: /etc/chrony/chrony.conf
2019-05-14 19:00:15 +00:00
|
|
|
if apk audit "$(dirname "$1")" | grep -q "${1:1}"; then
|
|
|
|
echo "- NOT modifying (file was changed before): $1"
|
|
|
|
else
|
|
|
|
echo "- Modifying: $1"
|
2017-09-30 21:52:33 +00:00
|
|
|
cat > "$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install /etc/fstab
|
|
|
|
{
|
|
|
|
echo '# <file system> <mount point> <type> <options> <dump> <pass>'
|
|
|
|
echo 'LABEL="pmOS_root" / ext4 relatime,data=ordered 0 1'
|
|
|
|
echo 'LABEL="pmOS_boot" /boot auto defaults 0 2'
|
|
|
|
} | write_unless_modified /etc/fstab
|
2018-03-04 11:07:21 +00:00
|
|
|
|
2017-09-30 22:41:45 +00:00
|
|
|
# Set /etc/issue
|
2018-03-05 21:18:13 +00:00
|
|
|
{
|
2017-09-30 21:52:33 +00:00
|
|
|
echo 'Welcome to postmarketOS'
|
|
|
|
echo 'Kernel \r on an \m (\l)'
|
2017-10-02 22:41:19 +00:00
|
|
|
# setterm -powersave on -blank 5
|
|
|
|
echo -ne "\033[9;5]"
|
2018-03-05 21:18:13 +00:00
|
|
|
} | write_unless_modified /etc/issue
|
2018-03-04 11:07:21 +00:00
|
|
|
|
2017-09-30 22:41:45 +00:00
|
|
|
# Set /etc/motd
|
2017-09-30 21:52:33 +00:00
|
|
|
{
|
|
|
|
echo 'Welcome to postmarketOS!'
|
|
|
|
echo ''
|
|
|
|
echo 'This distribution is based on Alpine Linux.'
|
|
|
|
echo 'Read both our wikis to find a large amount of how-to guides and'
|
|
|
|
echo 'general information about administrating and development.'
|
|
|
|
echo 'See <https://wiki.postmarketos.org> and <https://wiki.alpinelinux.org>.'
|
|
|
|
echo ''
|
|
|
|
echo 'You may change this message by editing /etc/motd.'
|
|
|
|
echo ''
|
|
|
|
} | write_unless_modified /etc/motd
|
2017-07-25 05:02:51 +00:00
|
|
|
|
|
|
|
# Enable syslog to SHM. Note: size is 4048KiB, which *should* be More Than Enough(TM) for all but the most chattiest of devices.
|
main/postmarketos-base: fix wpa_supplicant config (!365)
Fix wifi on htc-ace by properly setting nl80211 before wext.
/etc/conf.d/wpa_supplicant is supposed to get modified twice with the
current code in the post-install file. The first one was patched
recently to set nl80211 before wext, but that change does not work in
practice, for two reasons:
1. The code block does not even get executed, because apk reports that
/etc/conf.d/wpa_supplicant was already modified (by a package that
was installed before, in its post-install script? I could not find
out which one does that though).
2. Even if it worked, the second code block would revert the change and
put wext before nl80211 again.
Fix this by removing the first code block, and changing the order in the
second one. Make it easier to catch such errors in the future, by
printing, which files get modified, or get skipped. Set "#!/bin/sh -e",
so the script can not fail silently.
When doing pmbootstrap -y zap and then pmbootstrap install, the output
looks like this:
(141/151) Installing postmarketos-base (3-r26)
Executing postmarketos-base-3-r26.post-install
- Modifying: /etc/fstab
- Modifying: /etc/issue
- Modifying: /etc/motd
- Modifying: /etc/conf.d/syslog
- Modifying: /etc/conf.d/wpa_supplicant
- Modifying: /etc/sudoers
- Modifying: /etc/chrony/chrony.conf
2019-05-14 19:00:15 +00:00
|
|
|
echo "- Modifying: /etc/conf.d/syslog"
|
2017-07-25 05:02:51 +00:00
|
|
|
sed s/=\"/=\""-C4048 "/ -i /etc/conf.d/syslog
|
2017-09-15 17:44:50 +00:00
|
|
|
|
main/postmarketos-base: fix wpa_supplicant config (!365)
Fix wifi on htc-ace by properly setting nl80211 before wext.
/etc/conf.d/wpa_supplicant is supposed to get modified twice with the
current code in the post-install file. The first one was patched
recently to set nl80211 before wext, but that change does not work in
practice, for two reasons:
1. The code block does not even get executed, because apk reports that
/etc/conf.d/wpa_supplicant was already modified (by a package that
was installed before, in its post-install script? I could not find
out which one does that though).
2. Even if it worked, the second code block would revert the change and
put wext before nl80211 again.
Fix this by removing the first code block, and changing the order in the
second one. Make it easier to catch such errors in the future, by
printing, which files get modified, or get skipped. Set "#!/bin/sh -e",
so the script can not fail silently.
When doing pmbootstrap -y zap and then pmbootstrap install, the output
looks like this:
(141/151) Installing postmarketos-base (3-r26)
Executing postmarketos-base-3-r26.post-install
- Modifying: /etc/fstab
- Modifying: /etc/issue
- Modifying: /etc/motd
- Modifying: /etc/conf.d/syslog
- Modifying: /etc/conf.d/wpa_supplicant
- Modifying: /etc/sudoers
- Modifying: /etc/chrony/chrony.conf
2019-05-14 19:00:15 +00:00
|
|
|
# Enable nl80211,wext & dbus control for wpa_supplicant
|
|
|
|
if ! grep -q Dnl80211,wext /etc/conf.d/wpa_supplicant; then
|
|
|
|
echo "- Modifying: /etc/conf.d/wpa_supplicant"
|
|
|
|
sed -i 's/wpa_supplicant_args=\"/wpa_supplicant_args=\" -u -Dnl80211,wext/' \
|
|
|
|
/etc/conf.d/wpa_supplicant
|
2017-09-15 17:44:50 +00:00
|
|
|
fi
|
|
|
|
touch /etc/wpa_supplicant/wpa_supplicant.conf
|
|
|
|
|
2017-10-12 20:08:10 +00:00
|
|
|
# Enable the 'wheel' group
|
main/postmarketos-base: fix wpa_supplicant config (!365)
Fix wifi on htc-ace by properly setting nl80211 before wext.
/etc/conf.d/wpa_supplicant is supposed to get modified twice with the
current code in the post-install file. The first one was patched
recently to set nl80211 before wext, but that change does not work in
practice, for two reasons:
1. The code block does not even get executed, because apk reports that
/etc/conf.d/wpa_supplicant was already modified (by a package that
was installed before, in its post-install script? I could not find
out which one does that though).
2. Even if it worked, the second code block would revert the change and
put wext before nl80211 again.
Fix this by removing the first code block, and changing the order in the
second one. Make it easier to catch such errors in the future, by
printing, which files get modified, or get skipped. Set "#!/bin/sh -e",
so the script can not fail silently.
When doing pmbootstrap -y zap and then pmbootstrap install, the output
looks like this:
(141/151) Installing postmarketos-base (3-r26)
Executing postmarketos-base-3-r26.post-install
- Modifying: /etc/fstab
- Modifying: /etc/issue
- Modifying: /etc/motd
- Modifying: /etc/conf.d/syslog
- Modifying: /etc/conf.d/wpa_supplicant
- Modifying: /etc/sudoers
- Modifying: /etc/chrony/chrony.conf
2019-05-14 19:00:15 +00:00
|
|
|
echo "- Modifying: /etc/sudoers"
|
2017-10-12 20:08:10 +00:00
|
|
|
sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers
|
|
|
|
|
2019-12-26 15:45:16 +00:00
|
|
|
# Set chrony to quickly correct system time whenever it differs from
|
|
|
|
# ntp time by more than 1s.
|
2017-10-13 19:18:24 +00:00
|
|
|
if ! grep -q "makestep" /etc/chrony/chrony.conf; then
|
2019-12-26 15:45:16 +00:00
|
|
|
echo "- Modifying: /etc/chrony/chrony.conf (adding makestep)"
|
2017-10-13 19:18:24 +00:00
|
|
|
echo "makestep 1 -1" >> /etc/chrony/chrony.conf
|
|
|
|
fi
|
2019-12-26 15:45:16 +00:00
|
|
|
|
|
|
|
# Comment out initstepslew in the chrony configuration to avoid a delay
|
|
|
|
# during boot.
|
|
|
|
if grep -q "^initstepslew" /etc/chrony/chrony.conf; then
|
|
|
|
echo "- Modifying: /etc/chrony/chrony.conf (removing initstepslew)"
|
|
|
|
sed -i 's/^initstepslew/#initstepslew/' /etc/chrony/chrony.conf
|
|
|
|
fi
|
2020-05-10 16:08:33 +00:00
|
|
|
|
|
|
|
exit 0
|