Skip to content

Commit

Permalink
installer: add cron to installation
Browse files Browse the repository at this point in the history
This patch adds an option to set up two cron jobs, one for tmux and one for interval.

Signed-off-by: Amy Parker <amy@amyip.net>
  • Loading branch information
amyipdev committed Aug 4, 2023
1 parent 8ce19f8 commit 044c318
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
13 changes: 13 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions srv/tmux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# ssvp: server statistics viewer project
# Copyright (C) 2023 Amy Parker <amy@amyip.net>
#
# 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

0 comments on commit 044c318

Please sign in to comment.