Skip to content

Commit

Permalink
Merge pull request #662 from atsign-foundation/sshnpd-installer
Browse files Browse the repository at this point in the history
fix: sshnpd/rvd installer tweaks
  • Loading branch information
XavierChanth authored Jan 4, 2024
2 parents baadb1b + 0d304ae commit c519c05
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
5 changes: 5 additions & 0 deletions packages/sshnoports/bundles/shell/headless/sshnpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions packages/sshnoports/bundles/shell/headless/sshrvd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions packages/sshnoports/bundles/shell/install.sh
Original file line number Diff line number Diff line change
@@ -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' ]
}
Expand Down Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions packages/sshnoports/bundles/shell/systemd/sshnpd.service
Original file line number Diff line number Diff line change
Expand Up @@ -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=<username>
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 <device_name> -v

[Install]
Expand Down
7 changes: 6 additions & 1 deletion packages/sshnoports/bundles/shell/systemd/sshrvd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ Description=Ssh No Ports Rendezvous Daemon
After=network-online.target

[Service]
# TODO : set username
User=<username>
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 <internet_address>

[Install]
Expand Down

0 comments on commit c519c05

Please sign in to comment.