summaryrefslogtreecommitdiff
path: root/yams
blob: f6cad964b5d4b661e6e49e9f434518ac61f9a92e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
set -eo 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"
}

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
    echo "Getting your IP..."
    your_ip=$(curl -s ifconfig.me)
    echo "$your_ip"
    echo
    if [ $qbittorrent_ip == $your_ip ]; then
	   echo "Your IPs are the same! qBittorrent is NOT working!"
	   exit 255
   else
	   echo "Your IPs are different. qBittorrent is working as expected!"
    	   exit 0
   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