diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..59b3ea1 --- /dev/null +++ b/install.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# This script will set up a basic systemd service and timer for DiscoRSS +# You can optionally edit the entries here before running it, or you can +# use systemctl --user edit --full discorss.service or discorss.timer +# after installing them. + +cat << EOF > discorss.service +[Unit] +Description=Discord RSS feeder +Wants=discorss.timer + +[Service] +Type=oneshot +ExecStart=/home/amr/workspace/python/discorss/discorss.py + +[Install] +WantedBy=default.target + +EOF + +cat << EOF > discorss.timer +[Unit] +Description=Timer for DiscoRSS +Requires=discorss.service + +[Timer] +Unit=discorss.service +OnCalendar=*:0/5:00 +AccuracySec=1s + +[Install] +WantedBy=timers.target + +EOF + +cp discorss.service ~/.config/systemd/user/ +cp discorss.timer ~/.config/systemd/user/ + +systemctl --user daemon-reload + +printf "Would you like a basic example config created for you? [y/n]" +read answer1 +if [ "$answer1" =~ ^[yYnN]$ ]; then + mkdir -p -v ~/.config/discorss + cat << EOF > ~/.config/discorss/discorss.conf +{ + "feeds": [ + { + "name": "Phoronix", + "siteurl": "https://www.phoronix.com/", + "url": "http://www.phoronix.com/rss.php", + "webhook": "PASTE WEBHOOK URL HERE", + "offset": 0, + } + ], +} +EOF + printf "Make sure to edit ~/.config/discorss/discorss.conf and add in your custom feeds and webhook URLS! The script will just error out if you don't do this." +else + printf "Make sure to create a config at ~/.config/discorss/discorss.conf and follow the pattern shown in the README." +fi + +printf "Would you like to have the timer enabled and started now? [y/n]" +read answer +if [ "$answer" =~ ^[yYnN]$ ]; then + systemctl --user enable --now discorss.timer + printf "discorss.timer enabled and started. Don't enable or start discorss.service -- the timer does this automatically." +else + printf "Don't forget to run systemctl --user enable --now discorss.timer when you are ready! Don't enable or start discorss.service -- the timer does this automatically." +fi + +printf "You should be almost ready to go! Double-check your config files, and check systemctl --user list-timers once the discorss.timer is enabled to see when it will fire next. The default is every 5 minutes." + +printf "Remember, if you need help or encounter any bugs, contact me via the issues tracker on the git repository where you got this from!"