forked from MiczFlor/RPi-Jukebox-RFID
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: outsource boot_logs and systemctl_services
- Loading branch information
Showing
3 changed files
with
110 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
source ../includes/02_helpers.sh | ||
|
||
if [ -z "$1" ] || { [ "$1" != "enable" ] && [ "$1" != "disable" ]; }; then | ||
print_lc "Error: Invalid or no argument provided. | ||
Usage: ./boot_logs.sh <arg> | ||
where <arg> can be 'enable' or 'disable'" | ||
exit 1 | ||
fi | ||
|
||
arg="$1" | ||
boot_cmdline_path=$(get_boot_cmdline_path) | ||
boot_cmdline_options="consoleblank=1 logo.nologo quiet loglevel=0 plymouth.enable=0 vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fastboot noatime nodiratime noram" | ||
|
||
if [ "$arg" = "enable" ]; then | ||
print_lc "Enable Boot logs..." | ||
|
||
if [ -s "${boot_cmdline_path}" ]; then | ||
for option in $boot_cmdline_options; do | ||
sudo sed -i "s/\s*$option\s*/ /" "${boot_cmdline_path}" | ||
done | ||
fi | ||
elif [ "$arg" = "disable" ]; then | ||
print_lc "Disable Boot logs..." | ||
|
||
if [ ! -s "${boot_cmdline_path}" ];then | ||
sudo tee "${boot_cmdline_path}" <<-EOF | ||
${boot_cmdline_options} | ||
EOF | ||
else | ||
for option in $boot_cmdline_options | ||
do | ||
if ! grep -qiw "$option" "${boot_cmdline_path}" ; then | ||
sudo sed -i "s/$/ $option/" "${boot_cmdline_path}" | ||
fi | ||
done | ||
fi | ||
fi | ||
|
||
# Test | ||
if [ "$arg" = "enable" ]; then | ||
for option in $boot_cmdline_options | ||
do | ||
verify_file_does_not_contain_string $option "${boot_cmdline_path}" | ||
done | ||
elif [ "$arg" = "disable" ]; then | ||
for option in $boot_cmdline_options | ||
do | ||
verify_file_contains_string_once $option "${boot_cmdline_path}" | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
source ../includes/02_helpers.sh | ||
|
||
if [ -z "$1" ] || { [ "$1" != "enable" ] && [ "$1" != "disable" ]; }; then | ||
print_lc "Error: Invalid or no argument provided. | ||
Usage: ./systemctl_services.sh <arg> | ||
where <arg> can be 'enable' or 'disable'" | ||
exit 1 | ||
fi | ||
|
||
arg="$1" | ||
|
||
if [ "$arg" = "enable" ]; then | ||
print_lc "Enable default services..." | ||
|
||
sudo systemctl enable keyboard-setup.service | ||
sudo systemctl enable triggerhappy.service | ||
sudo systemctl enable triggerhappy.socket | ||
sudo systemctl enable raspi-config.service | ||
sudo systemctl enable apt-daily.service | ||
sudo systemctl enable apt-daily-upgrade.service | ||
sudo systemctl enable apt-daily.timer | ||
sudo systemctl enable apt-daily-upgrade.timer | ||
elif [ "$arg" = "disable" ]; then | ||
print_lc "Disable default services..." | ||
|
||
sudo systemctl disable keyboard-setup.service | ||
sudo systemctl disable triggerhappy.service | ||
sudo systemctl disable triggerhappy.socket | ||
sudo systemctl disable raspi-config.service | ||
sudo systemctl disable apt-daily.service | ||
sudo systemctl disable apt-daily-upgrade.service | ||
sudo systemctl disable apt-daily.timer | ||
sudo systemctl disable apt-daily-upgrade.timer | ||
fi | ||
|
||
# Test | ||
if [ "$arg" = "enable" ]; then | ||
verify_optional_service_enablement keyboard-setup.service enabled | ||
verify_optional_service_enablement triggerhappy.service enabled | ||
verify_optional_service_enablement triggerhappy.socket enabled | ||
verify_optional_service_enablement raspi-config.service enabled | ||
verify_optional_service_enablement apt-daily.service enabled | ||
verify_optional_service_enablement apt-daily-upgrade.service enabled | ||
verify_optional_service_enablement apt-daily.timer enabled | ||
verify_optional_service_enablement apt-daily-upgrade.timer enabled | ||
|
||
elif [ "$arg" = "disable" ]; then | ||
verify_optional_service_enablement keyboard-setup.service disabled | ||
verify_optional_service_enablement triggerhappy.service disabled | ||
verify_optional_service_enablement triggerhappy.socket disabled | ||
verify_optional_service_enablement raspi-config.service disabled | ||
verify_optional_service_enablement apt-daily.service disabled | ||
verify_optional_service_enablement apt-daily-upgrade.service disabled | ||
verify_optional_service_enablement apt-daily.timer disabled | ||
verify_optional_service_enablement apt-daily-upgrade.timer disabled | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters