From 044c318a28c9b3f6778bf2a559bbbdf5e6eaf0bb Mon Sep 17 00:00:00 2001 From: Amy Parker Date: Thu, 3 Aug 2023 21:34:37 -0700 Subject: [PATCH] installer: add cron to installation This patch adds an option to set up two cron jobs, one for tmux and one for interval. Signed-off-by: Amy Parker --- install.sh | 13 +++++++++++++ srv/tmux.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 srv/tmux.sh diff --git a/install.sh b/install.sh index 0c5f187..b006539 100755 --- a/install.sh +++ b/install.sh @@ -118,6 +118,19 @@ fi $PREROOT make install INSTALLDIR=$INSDIR +echo -n "Choose an autorunner method (cron/[none]): " +read ATRMTH +if [ "$ATRMTH" == "cron" ]; then + (crontab -l; echo "*/5 * * * * $INSDIR/venv/bin/python3 $INSDIR/srv/interval.py") | crontab - + echo "Cron runner installed" +fi + +echo -n "Choose a server reboot launch method (cron/[none]): " +read RBTLNC +if [ "$RBTLNC" == "cron" ]; then + (crontab -l; echo "@reboot $INSDIR/srv/tmux.sh") | crontab - +fi + echo "Installation finished. Remember to set up a cron job for srv/interval.py to run every 5 minutes (this will be automated in the future)" # next todo: cron (also implement systemd timers) diff --git a/srv/tmux.sh b/srv/tmux.sh new file mode 100755 index 0000000..e990a7b --- /dev/null +++ b/srv/tmux.sh @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# ssvp: server statistics viewer project +# Copyright (C) 2023 Amy Parker +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA or visit the +# GNU Project at https://gnu.org/licenses. The GNU Affero General Public +# License version 3 is available at, for your convenience, +# https://www.gnu.org/licenses/agpl-3.0.en.html. + +cd "$(dirname "$0")" +source ../venv/bin/activate +tmux new-session -d -s ENTER +tmux detach -s ENTER +tmux send-keys -t 0 "./gunicorn.sh" ENTER \ No newline at end of file