put prompt/install/config into own files

This commit is contained in:
Mario Fetka
2024-04-20 10:00:07 +02:00
parent 294dce1e74
commit f5dba27ec6
23 changed files with 143 additions and 134 deletions

View File

@@ -2,9 +2,9 @@
MYSTIC_DIR="$1"
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-start.sh > ${MYSTIC_DIR}/mrc_server-start
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc_server-start.sh > ${MYSTIC_DIR}/mrc_server-start
chmod +x ${MYSTIC_DIR}/mrc_server-start
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-stop.sh > ${MYSTIC_DIR}/mrc_server-stop
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc_server-stop.sh > ${MYSTIC_DIR}/mrc_server-stop
chmod +x ${MYSTIC_DIR}/mrc_server-stop
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-server.service > /etc/systemd/system/mrc-server.service
systemctl daemon-reload

View File

@@ -1,7 +1,7 @@
#!/bin/bash
#==================================================================================================
# This shell script will launch the 'Multi Relay Chat' python script. It is intended to be called #
# via a forked systemd .service file. The script will check that mrc_client.py is not already #
# via a forked systemd .service file. The script will check that mrc_server.py is not already #
# running then will launch it. To avoid problems, it should be launched using the same user that #
# owns the mystic install directory. If executing manually, use 'sudo -u username' or ensure you #
# are logged into the terminal as the user that owns the mystic directory. In a systemd .service #
@@ -12,34 +12,34 @@
# MRC Variables:
MRC_PATH=@MYSTIC_DIR@
MRC_SERVER=mrc.bottomlessabyss.net
MRC_SERVER=0.0.0.0
MRC_PORT=5000
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_server.py" | grep -v grep | awk '{print $2}')
echo "Attempting to start the Multi Relay Chat (MRC) python script.."
echo "Attempting to start the Multi Relay Chat Server (MRC) python script.."
# Make sure the mrc_client.py script isn't already running:
# Make sure the mrc_server.py script isn't already running:
if [ ! -z "$MRC_PID" ]
then
echo "Error: mrc_client.py script is already running at PID $MRC_PID. Stop it first."
echo "Error: mrc_server.py script is already running at PID $MRC_PID. Stop it first."
exit 1
fi
# Starting the MRC python script
cd $MRC_PATH >/dev/null
/usr/bin/python2 ./mrc_client.py $MRC_SERVER $MRC_PORT &
/usr/bin/python2 ./mrc_server.py $MRC_SERVER:$MRC_PORT > logs/mrcserver.log 2>&1 &
cd - >/dev/null
# Wait 3 seconds and check for a PID
sleep 3
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_server.py" | grep -v grep | awk '{print $2}')
# Making sure it started successfully
if [ ! -z "$MRC_PID" ]
then
echo "Success! The mrc_client.py script is now running with PID $MRC_PID"
echo "Success! The mrc_server.py script is now running with PID $MRC_PID"
exit 0
else
echo "Error: mrc_client.py failed to start. Exiting."
echo "Error: mrc_server.py failed to start. Exiting."
exit 1
fi

View File

@@ -1,7 +1,7 @@
#!/bin/bash
#==================================================================================================
# This shell script will stop the 'Multi Relay Chat' python script. It is intended to be called #
# via a forked systemd .service file. The script will check that mrc_client.py is running then #
# This shell script will stop the 'Multi Relay server' python script. It is intended to be called #
# via a forked systemd .service file. The script will check that mrc_server.py is running then #
# will stop it via SIGTERM. If it can't be stopped gracefully within 30 seconds, it will be #
# forcefully stopped. The script will exit with an appropriate error code to indicate whether it #
# was successful or not. This script is indended to work only with Debian, Ubuntu, Raspbian and #
@@ -10,16 +10,16 @@
# MRC Variables. Be sure to set your MRC script path (usually your main mystic directory)
MRC_PATH=@MYSTIC_DIR@
MRC_SERVER=mrc.bottomlessabyss.net
MRC_SERVER=0.0.0.0
MRC_PORT=5000
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_server.py" | grep -v grep | awk '{print $2}')
echo "Attempting to stop the Multi Relay Chat (MRC) python script.."
echo "Attempting to stop the Multi Relay server (MRC) python script.."
# Make sure the mrc_client.py script is running:
# Make sure the mrc_server.py script is running:
if [ -z "$MRC_PID" ]
then
echo "Error: mrc_client.py is not running so can't be stopped."
echo "Error: mrc_server.py is not running so can't be stopped."
exit 1
fi
@@ -33,13 +33,13 @@ echo "Checking to ensure the process stops.."
while [ $MRC_COUNTER -lt 6 ]
do
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_server.py" | grep -v grep | awk '{print $2}')
if [ ! -z "$MRC_PID" ]
then
echo "Process still running. Waiting 5 seconds.."
sleep 5
else
echo "Finished! mrc_client.py script has been stopped successfully."
echo "Finished! mrc_server.py script has been stopped successfully."
exit 0
fi
let MRC_COUNTER=MRC_COUNTER+1
@@ -48,18 +48,18 @@ done
# If it's still running after 30 seconds (6 intervals) then use kill -9
if [ "$MRC_COUNTER" -eq 6 ] && [ ! -z "$MRC_PID" ]
then
echo "The mrc_client.py script failed to stop after 60 seconds. Stopping forcefully.."
echo "The mrc_server.py script failed to stop after 60 seconds. Stopping forcefully.."
kill -9 $MRC_PID
fi
# Wait 5 seconds, then double check to ensure it stopped. Otherwise it's considered a failure.
sleep 5
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_server.py" | grep -v grep | awk '{print $2}')
if [ ! -z "$MRC_PID" ]
then
echo "Error: Failed to kill the mrc_client.py script."
echo "Error: Failed to kill the mrc_server.py script."
exit 1
else
echo "Success. The mrc_client.py script was forcefully stopped."
echo "Success. The mrc_server.py script was forcefully stopped."
exit 0
fi

0
mrc-server/prompt-v1.sh Normal file
View File