diff options
author | Roger Gonzalez <roger@rogs.me> | 2023-10-21 22:17:08 +0000 |
---|---|---|
committer | Roger Gonzalez <roger@rogs.me> | 2023-10-21 22:17:08 +0000 |
commit | 7eb39c8d68cde489aaf1672ac75dc39242c098e5 (patch) | |
tree | 9d6ae22d68eb8f281fb4efd4bd9102052a7365e8 /yams | |
parent | e2cda39364463e092acf72c7a32989a7182796ad (diff) | |
parent | aee33be7a0d137dcd1c9cbc7e959413d1114725e (diff) |
Merge branch 'feature/refactor-to-literate' into 'v2'
Refactored YAMS to literate
See merge request rogs/yams!10
Diffstat (limited to 'yams')
-rwxr-xr-x | yams | 52 |
1 files changed, 41 insertions, 11 deletions
@@ -2,7 +2,8 @@ set -euo pipefail -dc="docker-compose -f <filename>" +dc="docker-compose -f <filename> -f <custom_file_filename>" +install_location="<install_location>" option=${1:-"--help"} @@ -17,40 +18,41 @@ help() { 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" + echo "update updates YAMS" } send_success_message() { - echo -e $(printf "\e[32m$1\e[0m") + echo -e "$(printf "\e[32m$1\e[0m")" } send_error_message() { - echo -e $(printf "\e[31m$1\e[0m") + echo -e "$(printf "\e[31m$1\e[0m")" exit 255 } -if [ $option == "--help" ]; then +if [ "$option" == "--help" ]; then help exit 0 fi -if [ $option == "restart" ]; then +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 +if [ "$option" == "stop" ]; then $dc stop exit 0 fi -if [ $option == "start" ]; then +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 +if [ "$option" == "check-vpn" ]; then echo "Getting your qBittorrent IP..." qbittorrent_ip=$(docker exec qbittorrent sh -c "curl -s ifconfig.me"); echo "$qbittorrent_ip" @@ -61,19 +63,19 @@ if [ $option == "check-vpn" ]; then echo "$your_ip" echo "Your local IP country is $(curl -s https://am.i.mullvad.net/country)" echo - if [ $qbittorrent_ip == $your_ip ]; then + 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 +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 + if [ "$destroy_now" == "y" ]; then $dc down echo echo @@ -81,3 +83,31 @@ if [ $option == "destroy" ]; then echo "\$ yams start" fi fi + +if [ "$option" == "update" ]; then + echo "Updating YAMS..." + $dc stop + rm -rf /tmp/yams && mkdir /tmp/yams + wget https://gitlab.com/rogs/yams/-/raw/master/docker-compose.example.yaml -O /tmp/yams/docker-compose.example.yml > /dev/null 2>&1 + source $install_location/.env + + filename="$install_location/docker-compose.yaml" + + cp /tmp/yams/docker-compose.example.yml $filename + + + sed -i -e "s;<media_service>;$MEDIA_SERVICE;g" "$filename" + if [ "$MEDIA_SERVICE" == "plex" ]; then + sed -i -e "s;#network_mode: host # plex;network_mode: host # plex;g" "$filename" + fi + + if [ "$VPN_ENABLED" == "y" ]; then + sed -i -e "s;#network_mode: \"service:gluetun\";network_mode: \"service:gluetun\";g" "$filename" \ + -e "s;ports: # qbittorrent;#port: # qbittorrent;g" "$filename" \ + -e "s;- 8080:8080 # qbittorrent;#- 8080:8080 # qbittorrent;g" "$filename" \ + -e "s;#- 8080:8080/tcp # gluetun;- 8080:8080/tcp # gluetun;g" "$filename" + fi + + $dc up -d + echo "YAMS was updated and it is starting. Wait 1 min until all the services are up and running..." +fi |