From d961839137f4ff6282fe91eb66264c77fc1e2c6a Mon Sep 17 00:00:00 2001 From: openoms <43343391+openoms@users.noreply.github.com> Date: Fri, 5 Apr 2024 08:33:08 +0200 Subject: [PATCH] prevent sleep and "unable to resolve host debian" error (#151) * prevent sleep and "unable to resolve host debian" error * fomat script --- build_joininbox.sh | 23 ++++++++++++++++++++++- scripts/set.ssh.sh | 6 +++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/build_joininbox.sh b/build_joininbox.sh index 9883eba..85bc85b 100644 --- a/build_joininbox.sh +++ b/build_joininbox.sh @@ -90,7 +90,28 @@ echo "# Preparing the base image" echo "############################" echo -echo "# Prepare ${baseImage} " +echo "# Prevent sleep" # on all platforms https://wiki.debian.org/Suspend +systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target +mkdir /etc/systemd/sleep.conf.d +echo "[Sleep] +AllowSuspend=no +AllowHibernation=no +AllowSuspendThenHibernate=no +AllowHybridSleep=no" | tee /etc/systemd/sleep.conf.d/nosuspend.conf +mkdir /etc/systemd/logind.conf.d +echo "[Login] +HandleLidSwitch=ignore +HandleLidSwitchDocked=ignore" | tee /etc/systemd/logind.conf.d/nosuspend.conf + +# check if /etc/hosts already has debian entry +# prevent "unable to resolve host debian" error +isDebianInHosts=$(grep -c "debian" /etc/hosts) +if [ ${isDebianInHosts} -eq 0 ]; then + echo "# Adding debian to /etc/hosts" + echo "127.0.1.1 debian" | tee -a /etc/hosts > /dev/null + systemctl restart networking +fi + # special prepare on RPi if [ "${baseimage}" = "raspios" ] || [ "${baseimage}" = "debian_rpi64" ] || [ "${baseimage}" = "armbian" ]; then diff --git a/scripts/set.ssh.sh b/scripts/set.ssh.sh index 2aee01c..21edcdd 100755 --- a/scripts/set.ssh.sh +++ b/scripts/set.ssh.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ ${#1} -eq 0 ]||[ $1 = "-h" ]||[ $1 = "--help" ];then +if [ ${#1} -eq 0 ] || [ $1 = "-h" ] || [ $1 = "--help" ]; then echo "Enable or disable ssh access with the joinmarket user" echo "sudo set.ssh.sh [off|on]" echo @@ -18,7 +18,7 @@ if ! grep -Eq "^joinmarketSSH=" /home/joinmarket/joinin.conf; then fi echo -if [ "$1" = "off" ];then +if [ "$1" = "off" ]; then echo "# Disable ssh access with the joinmarket user" if ! grep -Eq "^DenyUsers joinmarket" /etc/ssh/sshd_config; then echo "DenyUsers joinmarket" | tee -a /etc/ssh/sshd_config @@ -35,4 +35,4 @@ elif [ "$1" = "on" ]; then else echo "# Invalid option $*" exit 1 -fi \ No newline at end of file +fi