84 lines
2.2 KiB
Bash
Executable File
84 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
|
|
dc="docker-compose -f <filename>"
|
|
|
|
option=${1:-"--help"}
|
|
|
|
help() {
|
|
echo "yams - Yet Another Media Server"
|
|
echo
|
|
echo "Usage: yams [--help|restart|stop|start|status]"
|
|
echo "options:"
|
|
echo "--help displays this help message"
|
|
echo "restart restarts yams services"
|
|
echo "stop stops all yams services"
|
|
echo "start starts yams services"
|
|
echo "destroy destroy yams services so you can start from scratch"
|
|
echo "check-vpn checks if the VPN is working as expected"
|
|
}
|
|
|
|
send_success_message() {
|
|
echo -e $(printf "\e[32m$1\e[0m")
|
|
}
|
|
|
|
send_error_message() {
|
|
echo -e $(printf "\e[31m$1\e[0m")
|
|
exit 255
|
|
}
|
|
|
|
if [ $option == "--help" ]; then
|
|
help
|
|
exit 0
|
|
fi
|
|
|
|
if [ $option == "restart" ]; then
|
|
$dc stop && $dc up -d
|
|
echo "YAMS is starting. Wait 1 min until all the services are up and running..."
|
|
exit 0
|
|
fi
|
|
|
|
if [ $option == "stop" ]; then
|
|
$dc stop
|
|
exit 0
|
|
fi
|
|
|
|
if [ $option == "start" ]; then
|
|
$dc up -d
|
|
echo "YAMS is starting. Wait 1 min until all the services are up and running..."
|
|
exit 0
|
|
fi
|
|
|
|
if [ $option == "check-vpn" ]; then
|
|
echo "Getting your qBittorrent IP..."
|
|
qbittorrent_ip=$($dc exec -it qbittorrent sh -c "curl -s ifconfig.me");
|
|
echo "$qbittorrent_ip"
|
|
echo "Your country in qBittorrent is $($dc exec -it qbittorrent sh -c 'curl -s https://am.i.mullvad.net/country')"
|
|
echo
|
|
echo "Getting your IP..."
|
|
your_ip=$(curl -s ifconfig.me)
|
|
echo "$your_ip"
|
|
echo "Your local IP country is $(curl -s https://am.i.mullvad.net/country)"
|
|
echo
|
|
if [ $qbittorrent_ip == $your_ip ]; then
|
|
send_error_message "Your IPs are the same! qBittorrent is NOT working! ⚠️"
|
|
else
|
|
send_success_message "Your IPs are different. qBittorrent is working as expected! ✅ "
|
|
fi
|
|
fi
|
|
|
|
if [ $option == "destroy" ]; then
|
|
echo
|
|
echo
|
|
read -p "Are you sure you want to destroy all your yams services? THIS IS NOT RECOVERABLE! ⚠️ ️🚨 [y/N]: " destroy_now
|
|
destroy_now=${destroy_now:-"n"}
|
|
if [ $destroy_now == "y" ]; then
|
|
$dc down
|
|
echo
|
|
echo
|
|
echo "yams services were destroyed. To restart, run: "
|
|
echo "\$ yams start"
|
|
fi
|
|
fi
|