Browse Source

refactor: remove duplicate code for creating unique tmux socket name

The code changes in `command_start.sh` and `linuxgsm.sh` refactor the creation of a unique tmux socket name. The duplicate code in `linuxgsm.sh` has been removed, resulting in cleaner and more efficient code.
pull/4304/head
Daniel Gibbs 2 years ago
parent
commit
edb8dc3a0b
  1. 13
      lgsm/modules/command_start.sh
  2. 9
      linuxgsm.sh

13
lgsm/modules/command_start.sh

@ -48,6 +48,19 @@ fn_start_tmux() {
fn_reload_startparameters
# Create uid to ensure unique tmux socket name.
if [ ! -f "${datadir}/${selfname}.uid" ]; then
check_status.sh
if [ "${status}" != "0" ]; then
# stop running server (if running) to prevent lingering tmux sessions.
exitbypass=1
command_stop.sh
fi
uid=$(date '+%s' | sha1sum | head -c 8)
echo "${uid}" > "${datadir}/${selfname}.uid"
socketname="${sessionname}-$(cat "${datadir}/${selfname}.uid")"
fi
if [ "${shortname}" == "av" ]; then
cd "${systemdir}" || exit
else

9
linuxgsm.sh

@ -414,15 +414,6 @@ else
fi
fi
# Create uid to ensure unique tmux socket name.
if [ ! -f "${datadir}/${selfname}.uid" ]; then
# stop running server (if running) to prevent lingering tmux sessions.
exitbypass=1
uid=$(date '+%s' | sha1sum | head -c 8)
echo "${uid}" > "${datadir}/${selfname}.uid"
socketname="${sessionname}-$(cat "${datadir}/${selfname}.uid")"
fi
# Load the IP details before the first config is loaded.
check_ip.sh
# Configs have to be loaded twice to allow start startparameters to pick up all vars

Loading…
Cancel
Save