diff --git a/packages/sshnoports/bundles/shell/headless/sshnpd.sh b/packages/sshnoports/bundles/shell/headless/sshnpd.sh index 9c9e235bd..6d1df0720 100755 --- a/packages/sshnoports/bundles/shell/headless/sshnpd.sh +++ b/packages/sshnoports/bundles/shell/headless/sshnpd.sh @@ -2,6 +2,11 @@ # disable "var is referenced but not assigned" warning for template # shellcheck disable=SC2154 +# Uncomment the following lines to specify your own values, or modify them inline below +# device_atsign="@example_device" +# manager_atsign="@example_client" +# device_name="default" + sleep 10; # allow machine to bring up network export USER="$user" while true; do diff --git a/packages/sshnoports/bundles/shell/headless/sshrvd.sh b/packages/sshnoports/bundles/shell/headless/sshrvd.sh index 7f02e288c..091c5eda3 100755 --- a/packages/sshnoports/bundles/shell/headless/sshrvd.sh +++ b/packages/sshnoports/bundles/shell/headless/sshrvd.sh @@ -2,6 +2,10 @@ # disable "var is referenced but not assigned" warning for template # shellcheck disable=SC2154 +# Uncomment the following lines to specify your own values, or modify them inline below +# atsign="@my_rvd" +# internet_address="127.0.0.1" + sleep 10; # allow machine to bring up network export USER="$user" while true; do diff --git a/packages/sshnoports/bundles/shell/install.sh b/packages/sshnoports/bundles/shell/install.sh index 6e20b2f8d..f0561038c 100755 --- a/packages/sshnoports/bundles/shell/install.sh +++ b/packages/sshnoports/bundles/shell/install.sh @@ -1,22 +1,29 @@ #!/bin/sh # SYSTEM GIVENS # +is_root() { + [ "$(id -u)" -eq 0 ] +} + define_env() { script_dir="$(dirname -- "$( readlink -f -- "$0"; )")" bin_dir="/usr/local/bin" systemd_dir="/etc/systemd/system" - - user_home="$HOME" + if is_root; then + user="$SUDO_USER" + if [ -z "$user" ]; then + user="root" + fi + else + user="$USER" + fi + user_home=$(sudo -u "$user" sh -c 'echo $HOME') user_bin_dir="$user_home/.local/bin" user_sshnpd_dir="$user_home/.sshnpd" user_log_dir="$user_sshnpd_dir/logs" user_ssh_dir="$user_home/.ssh" } -is_root() { - [ "$(id -u)" -eq 0 ] -} - is_darwin() { [ "$(uname)" = 'Darwin' ] } @@ -85,6 +92,7 @@ install_single_binary() { cp "$script_dir/$1" "$dest/$1" echo "Installed $1 to $dest" if is_root & ! [ -f "$user_bin_dir/$1" ] ; then + mkdir -p "$user_bin_dir" ln -sf "$dest/$1" "$user_bin_dir/$1" echo "Linked $user_bin_dir/$1 to $dest" fi diff --git a/packages/sshnoports/bundles/shell/systemd/sshnpd.service b/packages/sshnoports/bundles/shell/systemd/sshnpd.service index 167d10bb5..6a05c8085 100644 --- a/packages/sshnoports/bundles/shell/systemd/sshnpd.service +++ b/packages/sshnoports/bundles/shell/systemd/sshnpd.service @@ -2,18 +2,23 @@ Description=Ssh No Ports Daemon After=network-online.target -# Uncomment the following line to make this unit fail if sshd isn't started -# Requisite=sshd.service +# Make this unit fail if sshd isn't started first +Requisite=sshd.service # Uncomment the following line to make this unit auto-start sshd if it isn't started # Requires=sshd.service [Service] +# TODO : set username User= Type=simple Restart=always RestartSec=3 -ExecStartPre=/bin/sleep 10 + +# Uncomment the following line to sleep for 10 seconds before starting up the service +# ExecStartPre=/bin/sleep 10 + +# TODO : set device_atsign, manager_atsign, device_name ExecStart=/usr/local/bin/sshnpd -a <@device_atsign> -m <@manager_atsign> -d -v [Install] diff --git a/packages/sshnoports/bundles/shell/systemd/sshrvd.service b/packages/sshnoports/bundles/shell/systemd/sshrvd.service index d75231c21..45aea48d4 100644 --- a/packages/sshnoports/bundles/shell/systemd/sshrvd.service +++ b/packages/sshnoports/bundles/shell/systemd/sshrvd.service @@ -3,11 +3,16 @@ Description=Ssh No Ports Rendezvous Daemon After=network-online.target [Service] +# TODO : set username User= Type=simple Restart=always RestartSec=3 -ExecStartPre=/bin/sleep 10 + +# Uncomment the following line to sleep for 10 seconds before starting up the service +# ExecStartPre=/bin/sleep 10 + +# TODO : set atsign, internet_address ExecStart=/usr/local/bin/sshrvd -a <@atsign> -i [Install]