Skip to content

Commit

Permalink
prevent sleep and "unable to resolve host debian" error (#151)
Browse files Browse the repository at this point in the history
* prevent sleep and "unable to resolve host debian" error

* fomat script
  • Loading branch information
openoms authored Apr 5, 2024
1 parent 0126005 commit d961839
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
23 changes: 22 additions & 1 deletion build_joininbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions scripts/set.ssh.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -35,4 +35,4 @@ elif [ "$1" = "on" ]; then
else
echo "# Invalid option $*"
exit 1
fi
fi

0 comments on commit d961839

Please sign in to comment.