change some of the logic
This commit is contained in:
+52
-45
@@ -1,53 +1,60 @@
|
||||
#DEBHELPER#
|
||||
#!/bin/bash
|
||||
|
||||
# DEBHELPER#
|
||||
|
||||
default_location="/usr/bin/nym-gateway"
|
||||
default_user="nym"
|
||||
default_group="nym"
|
||||
|
||||
existing_binary=$(sudo find / \( -path /proc -o -path /sys -o -path /dev -o -path /mnt -o -path /media \) -prune -o -type f -name nym-gateway -print 2>/dev/null)
|
||||
# We're assuming there's only two binaries on the machine, one is the newly installed app package version, and the second the existing binary, thus the logic below applies
|
||||
existing_binaries=$(sudo find / \( -path /proc -o -path /sys -o -path /dev -o -path /mnt -o -path /media \) -prune -o -type f -name "nym-gateway" -print 2>/dev/null)
|
||||
oldest_binary=$(ls -ltr $existing_binaries | head -n 1 | awk '{print $NF}')
|
||||
|
||||
if [[ -n "$existing_binary" ]] && [[ "$existing_binary" != "/usr/bin/nym-gateway" ]]; then
|
||||
echo "existing binary found at $existing_binary"
|
||||
|
||||
backup_path="${existing_binary}.backup"
|
||||
echo "backing up the original binary to $backup_path"
|
||||
sudo cp "$existing_binary" "$backup_path"
|
||||
|
||||
original_user=$(sudo stat -c "%U" "$existing_binary")
|
||||
original_group=$(sudo stat -c "%G" "$existing_binary")
|
||||
|
||||
echo "moving new binary from /usr/bin/nym-gateway to $existing_binary"
|
||||
sudo mv "/usr/bin/nym-gateway" "$existing_binary"
|
||||
|
||||
echo "changing ownership to $original_user:$original_group"
|
||||
sudo chown "$original_user":"$original_group" "$existing_binary"
|
||||
|
||||
original_perms=$(sudo stat -c "%a" "$backup_path")
|
||||
echo "setting permissions to $original_perms"
|
||||
sudo chmod "$original_perms" "$existing_binary"
|
||||
|
||||
echo "please restart the nym-gateway process to apply changes."
|
||||
echo "sometimes the gateways will require a re-init, but comms during releases should highlight this"
|
||||
echo "usually: systemctl restart nym-gateway.service"
|
||||
if [ -n "$oldest_binary" ] && [ "$oldest_binary" != "$default_location" ]; then
|
||||
echo "Existing binary found at $oldest_binary"
|
||||
|
||||
elif [[ ! -f "$default_location" ]]; then
|
||||
echo "no existing binary found, performing first-time installation."
|
||||
|
||||
if [[ -f "/usr/bin/nym-gateway" ]]; then
|
||||
echo "moving new binary to $default_location"
|
||||
sudo mv "/usr/bin/nym-gateway" "$default_location"
|
||||
|
||||
echo "setting default ownership to $default_user:$default_group"
|
||||
sudo chown "$default_user":"$default_group" "$default_location"
|
||||
|
||||
echo "setting default permissions"
|
||||
sudo chmod 755 "$default_location"
|
||||
|
||||
echo "installation complete. please configure and start the nym-gateway process manually."
|
||||
echo "please refer to https://nymtech.net/operators/nodes/gateway-setup.html"
|
||||
else
|
||||
echo "error: the new binary /usr/bin/nym-gateway does not exist."
|
||||
fi
|
||||
backup_path="${oldest_binary}.backup"
|
||||
echo "Backing up the original binary to $backup_path"
|
||||
sudo cp "$oldest_binary" "$backup_path"
|
||||
|
||||
original_user=$(sudo stat -c "%U" "$oldest_binary")
|
||||
original_group=$(sudo stat -c "%G" "$oldest_binary")
|
||||
|
||||
echo "Original group: $original_group"
|
||||
echo "Original user: $original_user"
|
||||
|
||||
echo "Moving new binary from $default_location to $oldest_binary"
|
||||
sudo mv "$default_location" "$oldest_binary"
|
||||
|
||||
echo "Changing ownership to $original_user:$original_group"
|
||||
sudo chown "$original_user":"$original_group" "$oldest_binary"
|
||||
|
||||
original_perms=$(sudo stat -c "%a" "$backup_path")
|
||||
echo "Setting permissions to $original_perms"
|
||||
sudo chmod "$original_perms" "$oldest_binary"
|
||||
|
||||
echo "Please restart the nym-gateway process to apply changes."
|
||||
echo "Sometimes the gateways will require a re-init, but comms during releases should highlight this."
|
||||
echo "Usually: systemctl restart nym-gateway.service"
|
||||
|
||||
elif [ ! -f "$default_location" ]; then
|
||||
echo "No existing binary found, performing first-time installation."
|
||||
|
||||
if [ -f "/usr/bin/nym-gateway" ]; then
|
||||
echo "Moving new binary to $default_location"
|
||||
sudo mv "/usr/bin/nym-gateway" "$default_location"
|
||||
|
||||
echo "Setting default ownership to $default_user:$default_group"
|
||||
sudo chown "$default_user":"$default_group" "$default_location"
|
||||
|
||||
echo "Setting default permissions"
|
||||
sudo chmod 755 "$default_location"
|
||||
|
||||
echo "Installation complete. Please configure and start the nym-gateway process manually."
|
||||
echo "Please refer to https://nymtech.net/operators/nodes/gateway-setup.html"
|
||||
else
|
||||
echo "Error: the new binary /usr/bin/nym-gateway does not exist."
|
||||
fi
|
||||
else
|
||||
echo "the binary is already in the expected location ($default_location). no action taken."
|
||||
fi
|
||||
echo "The binary is already in the expected location ($default_location). No action taken."
|
||||
fi
|
||||
|
||||
+50
-43
@@ -1,53 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
default_location="/usr/bin/nym-mixnode"
|
||||
default_user="nym"
|
||||
default_group="nym"
|
||||
|
||||
existing_binary=$(sudo find / \( -path /proc -o -path /sys -o -path /dev -o -path /mnt -o -path /media \) -prune -o -type f -name nym-mixnode -print 2>/dev/null)
|
||||
# We're assuming there's only two binaries on the machine, one is the newly installed app package version, and the second the existing binary, thus the logic below applies
|
||||
existing_binaries=$(sudo find / \( -path /proc -o -path /sys -o -path /dev -o -path /mnt -o -path /media \) -prune -o -type f -name "nym-mixnode" -print 2>/dev/null)
|
||||
oldest_binary=$(ls -ltr $existing_binaries | head -n 1 | awk '{print $NF}')
|
||||
|
||||
if [[ -n "$existing_binary" ]] && [[ "$existing_binary" != "/usr/bin/nym-mixnode" ]]; then
|
||||
echo "existing binary found at $existing_binary"
|
||||
|
||||
backup_path="${existing_binary}.backup"
|
||||
echo "backing up the original binary to $backup_path"
|
||||
sudo cp "$existing_binary" "$backup_path"
|
||||
|
||||
original_user=$(sudo stat -c "%U" "$existing_binary")
|
||||
original_group=$(sudo stat -c "%G" "$existing_binary")
|
||||
|
||||
echo "moving new binary from /usr/bin/nym-mixnode to $existing_binary"
|
||||
sudo mv "/usr/bin/nym-mixnode" "$existing_binary"
|
||||
|
||||
echo "changing ownership to $original_user:$original_group"
|
||||
sudo chown "$original_user":"$original_group" "$existing_binary"
|
||||
|
||||
original_perms=$(sudo stat -c "%a" "$backup_path")
|
||||
echo "setting permissions to $original_perms"
|
||||
sudo chmod "$original_perms" "$existing_binary"
|
||||
|
||||
echo "please restart the nym-mixnode process to apply changes."
|
||||
echo "sometimes the mixnode will require a re-init, but comms during releases should highlight this"
|
||||
echo "usually: systemctl restart nym-mixnode.service"
|
||||
if [ -n "$oldest_binary" ] && [ "$oldest_binary" != "$default_location" ]; then
|
||||
echo "Existing binary found at $oldest_binary"
|
||||
|
||||
backup_path="${oldest_binary}.backup"
|
||||
echo "Backing up the original binary to $backup_path"
|
||||
sudo cp "$oldest_binary" "$backup_path"
|
||||
|
||||
original_user=$(sudo stat -c "%U" "$oldest_binary")
|
||||
original_group=$(sudo stat -c "%G" "$oldest_binary")
|
||||
|
||||
echo "Original group: $original_group"
|
||||
echo "Original user: $original_user"
|
||||
|
||||
echo "Moving new binary from $default_location to $oldest_binary"
|
||||
sudo mv "$default_location" "$oldest_binary"
|
||||
|
||||
echo "Changing ownership to $original_user:$original_group"
|
||||
sudo chown "$original_user":"$original_group" "$oldest_binary"
|
||||
|
||||
original_perms=$(sudo stat -c "%a" "$backup_path")
|
||||
echo "Setting permissions to $original_perms"
|
||||
sudo chmod "$original_perms" "$oldest_binary"
|
||||
|
||||
echo "Please restart the nym-mixnode process to apply changes."
|
||||
echo "Sometimes the mixnode will require a re-init, but comms during releases should highlight this"
|
||||
echo "Usually: systemctl restart nym-mixnode.service"
|
||||
|
||||
elif [[ ! -f "$default_location" ]]; then
|
||||
echo "no existing binary found, performing first-time installation."
|
||||
|
||||
if [[ -f "/usr/bin/nym-mixnode" ]]; then
|
||||
echo "moving new binary to $default_location"
|
||||
sudo mv "/usr/bin/nym-mixnode" "$default_location"
|
||||
|
||||
echo "setting default ownership to $default_user:$default_group"
|
||||
sudo chown "$default_user":"$default_group" "$default_location"
|
||||
|
||||
echo "setting default permissions"
|
||||
sudo chmod 755 "$default_location"
|
||||
|
||||
echo "installation complete. please configure and start the nym-mixnode process manually."
|
||||
echo "please refer to https://nymtech.net/operators/nodes/mix-node-setup.html"
|
||||
else
|
||||
echo "error: the new binary /usr/bin/nym-mixnode does not exist."
|
||||
fi
|
||||
echo "no existing binary found, performing first-time installation."
|
||||
|
||||
if [[ -f "/usr/bin/nym-mixnode" ]]; then
|
||||
echo "Moving new binary to $default_location"
|
||||
sudo mv "/usr/bin/nym-mixnode" "$default_location"
|
||||
|
||||
echo "Setting default ownership to $default_user:$default_group"
|
||||
sudo chown "$default_user":"$default_group" "$default_location"
|
||||
|
||||
echo "Setting default permissions"
|
||||
sudo chmod 755 "$default_location"
|
||||
|
||||
echo "Installation complete. please configure and start the nym-mixnode process manually."
|
||||
echo "Please refer to https://nymtech.net/operators/nodes/mix-node-setup.html"
|
||||
else
|
||||
echo "Error: the new binary /usr/bin/nym-mixnode does not exist."
|
||||
fi
|
||||
else
|
||||
echo "the binary is already in the expected location ($default_location). no action taken."
|
||||
fi
|
||||
echo "The binary is already in the expected location ($default_location). No action taken."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user