add autoaupdater, update readme
autoupdater using systemd timer and service.
This commit is contained in:
13
README.md
13
README.md
@@ -1,11 +1,11 @@
|
||||
# **Kasane Teto in Your Terminal!**
|
||||
## **Find songs nobody knows exist!**
|
||||
A small wrapper and custom list for fortune/misfortune that picks a random Teto song of the day from any of almost 28,000 original, finished songs with videos on VocaDB.
|
||||
A small wrapper and custom list for fortune/misfortune that picks a random Teto song of the day from any of almost 28,000 original, finished songs with videos on VocaDB. Your original fortune command will remain untouched, tetosong just tells it to use a custom directory.
|
||||
|
||||
Now with optional Teto speaking in your terminal via ffplay! Just SV2, for now ;)
|
||||
https://github.com/user-attachments/assets/bc2a9909-d24a-43fa-882a-5e785cda3020
|
||||
|
||||
|
||||
<img src="tetosong.png" width="500">
|
||||
## **Now With Optional Automatic Updates!**
|
||||
Disabled by default, opt-in during setup to enable a systemd user service and timer to update the script and song list every Sunday at 5AM UTC. I check for new songs and push new tetofortunes from my server every Sunday at 3AM UTC
|
||||
|
||||
## **Dependencies**
|
||||
|
||||
@@ -14,7 +14,6 @@ fortune/fortune-mod or misfortune
|
||||
|
||||
ffmpeg -optional for speaking Teto
|
||||
|
||||
|
||||
### makefortune.sh
|
||||
fortune/fortune-mod (for strfile)
|
||||
|
||||
@@ -33,9 +32,7 @@ You can get your Teto song of the day by running:
|
||||
```bash
|
||||
tetosong
|
||||
```
|
||||
You can update the script and fortunes from github using:
|
||||
You can manually update the script and fortunes from github using:
|
||||
```bash
|
||||
tetosong -u
|
||||
```
|
||||
|
||||
Your original fortune command will remain untouched, tetosong just tells it to use a custom directory.
|
||||
|
||||
7
autoupdater/tetosong.service
Normal file
7
autoupdater/tetosong.service
Normal file
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=tetosong updater
|
||||
Wants=tetosong.timer
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/bash -c "curl -s file:///home/eric/GitHub/TetoSongOfTheDay/autoupdater/updater.sh | bash"
|
||||
10
autoupdater/tetosong.timer
Normal file
10
autoupdater/tetosong.timer
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Run tetosong service once a week
|
||||
|
||||
[Timer]
|
||||
OnCalendar=Sun *-*-* 05:00:00
|
||||
Persistent=true
|
||||
Unit=tetosong.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
34
autoupdater/updater.sh
Normal file
34
autoupdater/updater.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/bash
|
||||
# download custom fortunes and config file
|
||||
echo "Updating tetosong..."
|
||||
# check if the config file exists, if not download it and prompt the user for options.
|
||||
if [ ! -f ~/.local/share/tetosong/tetosong.config ]; then
|
||||
echo "Config file not found, downloading default..."
|
||||
curl -sLo ~/.local/share/tetosong/tetosong.config https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetosong.config
|
||||
fi
|
||||
mkdir -p ~/.local/share/tetosong
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes.dat https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes.dat
|
||||
curl -sLo ~/.local/share/tetosong/sv2SOTD.wav https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/sv2SOTD.wav
|
||||
|
||||
# set up autoupdater
|
||||
# # i use systemd, so i use systemd timers. I'll figure out something for non-systemd users later.
|
||||
AUTOUPDATE="$(. ~/.local/share/tetosong/tetosong.config; echo $AUTOUPDATE)"
|
||||
if [ "$AUTOUPDATE" = "YES" ]; then
|
||||
# write and enable systemd service file and timer user services
|
||||
echo "Auto-Updater enabled, updating service..."
|
||||
mkdir -p ~/.config/systemd/user
|
||||
curl -sLo ~/.config/systemd/user/tetosong.service https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/tetosong.service
|
||||
curl -sLo ~/.config/systemd/user/tetosong.timer https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/tetosong.timer
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable tetosong.timer
|
||||
systemctl --user start tetosong.timer
|
||||
else
|
||||
echo "Autoupdater disabled, skipping service update."
|
||||
fi
|
||||
# write tetosong to ~/.local/bin and tell the user how to use it.
|
||||
echo "writing tetosong to ~/.local/bin"
|
||||
mkdir -p ~/.local/bin
|
||||
curl -sLo ~/.local/bin/tetosong https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetosong
|
||||
chmod +x ~/.local/bin/tetosong
|
||||
echo "Update complete"
|
||||
33
installer.sh
33
installer.sh
@@ -14,20 +14,41 @@ fi
|
||||
|
||||
# download custom fortunes and config file
|
||||
echo "Downloading custom fortunes and config file..."
|
||||
mkdir -p ~/.local/share/tetosong
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes.dat https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes.dat
|
||||
curl -sLo ~/.local/share/tetosong/tetosong.config https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetosong.config
|
||||
curl -sLo ~/.local/share/tetosong/sv2SOTD.wav https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/sv2SOTD.wav
|
||||
# download the config file and prompt the user for options.
|
||||
|
||||
# prompt the user to hear Teto in their terminal
|
||||
curl -sLo ~/.local/share/tetosong/tetosong.config https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetosong.config
|
||||
read -p "Do you want to hear Teto in your terminal? (y/n) " yn
|
||||
case $yn in
|
||||
[Yy]* ) sed -i 's|^AUDIO=.*|AUDIO="YES"|' ~/.local/share/tetosong/tetosong.config ;;
|
||||
[Nn]* ) sed -i 's|^AUDIO=.*|AUDIO="NO"|' ~/.local/share/tetosong/tetosong.config ;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
read -p "Do you want to enable automatic updates? (y/n) " yn
|
||||
case $yn in
|
||||
[Yy]* ) sed -i 's|^AUTOUPDATE=.*|AUTOUPDATE="YES"|' ~/.local/share/tetosong/tetosong.config ;;
|
||||
[Nn]* ) sed -i 's|^AUTOUPDATE=.*|AUTOUPDATE="NO"|' ~/.local/share/tetosong/tetosong.config ;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
mkdir -p ~/.local/share/tetosong
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes
|
||||
curl -sLo ~/.local/share/tetosong/tetofortunes.dat https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/tetofortunes.dat
|
||||
curl -sLo ~/.local/share/tetosong/sv2SOTD.wav https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/sv2SOTD.wav
|
||||
|
||||
# set up autoupdater
|
||||
# i use systemd, so i use systemd timers. I'll figure out something for non-systemd users later.
|
||||
AUTOUPDATE="$(. ~/.local/share/tetosong/tetosong.config; echo $AUTOUPDATE)"
|
||||
if [ "$AUTOUPDATE" = "YES" ]; then
|
||||
# write and enable systemd service file and timer user services
|
||||
echo "Autoupdater enabled, updating service..."
|
||||
mkdir -p ~/.config/systemd/user
|
||||
curl -sLo ~/.config/systemd/user/tetosong.service https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/tetosong.service
|
||||
curl -sLo ~/.config/systemd/user/tetosong.timer https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/tetosong.timer
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable tetosong.timer
|
||||
systemctl --user start tetosong.timer
|
||||
else
|
||||
echo "Auto-Updater disabled, skipping service update."
|
||||
fi
|
||||
# write tetosong to ~/.local/bin and tell the user how to use it.
|
||||
echo "writing tetosong to ~/.local/bin"
|
||||
mkdir -p ~/.local/bin
|
||||
|
||||
4
tetosong
4
tetosong
@@ -3,8 +3,8 @@
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-u|--update)
|
||||
echo "Updating tetosong..."
|
||||
bash <(curl -s https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/installer.sh)
|
||||
echo "Downloading tetosong updater..."
|
||||
bash <(curl -s https://raw.githubusercontent.com/eric5949/tetosong/refs/heads/main/autoupdater/updater.sh)
|
||||
shift
|
||||
exit 0
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user