-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
227 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#/bin/bash | ||
# Set up the bot on the system as a container with auto-updates | ||
# from GitHub and automatic container rebuilding and restarting. | ||
# This script should be run interactively when setting up the bot | ||
# on a new system. | ||
|
||
WORKDIR=/var/cache/the-lone-dancer | ||
CONF_DIR=/etc/the-lone-dancer | ||
ENV_FILE=$CONF_DIR/.env | ||
TOKEN="" | ||
|
||
while [[ $# -gt 0 ]] | ||
do | ||
case $1 in | ||
--token) | ||
shift | ||
TOKEN=$1 | ||
;; | ||
--token-ask) | ||
shift | ||
echo -n "Paste your discord token here: " | ||
read -s TOKEN | ||
echo "" | ||
;; | ||
-h|--help) | ||
echo "$0 [-h|--help] [--token TOKEN] [--token-ask]" | ||
exit 0 | ||
;; | ||
*) | ||
;; | ||
esac | ||
done | ||
|
||
|
||
|
||
if ! grep the-lone-dancer /etc/passwd >/dev/null | ||
then | ||
# Create user | ||
useradd the-lone-dancer | ||
loginctl enable-linger the-lone-dancer | ||
fi | ||
|
||
if [[ ! -d $WORKDIR ]] | ||
then | ||
# Create/clone git repo | ||
git clone https://github.com/michael-je/the-lone-dancer.git $WORKDIR | ||
chown the-lone-dancer:the-lone-dancer $WORKDIR | ||
fi | ||
cd $WORKDIR | ||
|
||
if [[ ! -d $CONF_DIR ]] | ||
then | ||
# Create /etc/ directory | ||
mkdir $CONF_DIR | ||
fi | ||
|
||
if [[ ! -f $ENV_FILE ]] | ||
then | ||
# Copy env-file | ||
cp .env.example $ENV_FILE | ||
sed -i "s/DISCORD_TOKEN.*/DISCORD_TOKEN=$TOKEN/" $ENV_FILE | ||
fi | ||
|
||
cp the-lone-dancer*.service /etc/systemd/system/ | ||
cp the-lone-dancer*.timer /etc/systemd/system/ | ||
chmod +x update.sh | ||
cp update.sh /usr/local/bin/the-lone-dancer-update.sh | ||
systemctl daemon-reload | ||
systemctl enable the-lone-dancer.service | ||
systemctl enable --now the-lone-dancer-update.timer | ||
systemctl start the-lone-dancer-update.service | ||
/usr/local/bin/the-lone-dancer-update.sh -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#/bin/bash | ||
# Remove the bot as set up by setup.sh if you don't want it on your system | ||
# anymore. | ||
|
||
systemctl disable --now the-lone-dancer-update.timer | ||
systemctl disable --now the-lone-dancer-update.service | ||
systemctl disable --now the-lone-dancer.service | ||
rm /etc/systemd/system/the-lone-dancer* | ||
systemctl daemon-reload | ||
userdel --force the-lone-dancer | ||
rm -r /etc/the-lone-dancer | ||
rm -r /var/cache/the-lone-dancer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Unit] | ||
Description=The Lone Dancer updater | ||
After=basic.target | ||
|
||
[Service] | ||
Type=simple | ||
User=root | ||
ExecStart=/usr/local/bin/the-lone-dancer-update.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Unit] | ||
Description=Daily update of The Lone Dancer | ||
|
||
[Timer] | ||
OnCalendar=*-*-* 06:00:00 | ||
|
||
[Install] | ||
WantedBy=timers.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=The Lone Dancer | ||
After=basic.target | ||
|
||
[Service] | ||
Type=simple | ||
#Restart=always | ||
#RemainAfterExit=yes | ||
User=the-lone-dancer | ||
ExecStart=/usr/bin/podman start --attach the-lone-dancer | ||
#ExecReload=/usr/bin/podman restart the-lone-dancer | ||
ExecStop=/usr/bin/podman stop the-lone-dancer | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
Oops, something went wrong.