Merge branch 'feature/refactor-to-literate' into 'v2'

Refactored YAMS to literate

See merge request rogs/yams!10
This commit is contained in:
Roger Gonzalez 2023-10-21 22:17:08 +00:00
commit 7eb39c8d68
7 changed files with 951 additions and 354 deletions

12
.env.example Normal file
View File

@ -0,0 +1,12 @@
# Base configuration
PUID=<your_PUID>
PGID=<your_PGID>
MEDIA_DIRECTORY=<media_directory>
INSTALL_LOCATION=<install_directory>
MEDIA_SERVICE=<media_service>
# VPN configuration
VPN_ENABLED=<vpn_enabled>
VPN_SERVICE=<vpn_service>
VPN_USER=<vpn_user>
VPN_PASSWORD=<vpn_password>

View File

@ -0,0 +1,4 @@
version: "3"
# services:
# Add your custom services here!

View File

@ -3,17 +3,17 @@ version: "3"
services:
# <media_service> is used to serve your media to the client devices
<media_service>:
image: lscr.io/linuxserver/<media_service>
container_name: <media_service>
image: lscr.io/linuxserver/${MEDIA_SERVICE}
container_name: ${MEDIA_SERVICE}
#network_mode: host # plex
environment:
- PUID=<your_PUID>
- PGID=<your_PGID>
- PUID=${PUID}
- PGID=${PGID}
- VERSION=docker
volumes:
- <media_folder>/movies:/data/movies
- <media_folder>/tvshows:/data/tvshows
- <install_location>/config/<media_service>:/config
- ${MEDIA_DIRECTORY}/movies:/data/movies
- ${MEDIA_DIRECTORY}/tvshows:/data/tvshows
- ${INSTALL_LOCATION}/config/${MEDIA_SERVICE}:/config
ports:
- 8096:8096
restart: unless-stopped
@ -23,12 +23,12 @@ services:
image: lscr.io/linuxserver/qbittorrent
container_name: qbittorrent
environment:
- PUID=<your_PUID>
- PGID=<your_PGID>
- PUID=${PUID}
- PGID=${PGID}
- WEB_UI_PORT=8080
volumes:
- <media_folder>/downloads:/downloads
- <install_location>/config/qbittorrent:/config
- ${MEDIA_DIRECTORY}/downloads:/downloads
- ${INSTALL_LOCATION}/config/qbittorrent:/config
restart: unless-stopped
ports: # qbittorrent
- 8080:8080 # qbittorrent
@ -40,12 +40,12 @@ services:
image: lscr.io/linuxserver/sonarr
container_name: sonarr
environment:
- PUID=<your_PUID>
- PGID=<your_PGID>
- PUID=${PUID}
- PGID=${PGID}
volumes:
- <media_folder>/tvshows:/tv
- <media_folder>/downloads:/downloads
- <install_location>/config/sonarr:/config
- ${MEDIA_DIRECTORY}/tvshows:/tv
- ${MEDIA_DIRECTORY}/downloads:/downloads
- ${INSTALL_LOCATION}/config/sonarr:/config
ports:
- 8989:8989
restart: unless-stopped
@ -56,12 +56,12 @@ services:
image: lscr.io/linuxserver/radarr
container_name: radarr
environment:
- PUID=<your_PUID>
- PGID=<your_PGID>
- PUID=${PUID}
- PGID=${PGID}
volumes:
- <media_folder>/movies:/movies
- <media_folder>/downloads:/downloads
- <install_location>/config/radarr:/config
- ${MEDIA_DIRECTORY}/movies:/movies
- ${MEDIA_DIRECTORY}/downloads:/downloads
- ${INSTALL_LOCATION}/config/radarr:/config
ports:
- 7878:7878
restart: unless-stopped
@ -72,12 +72,12 @@ services:
image: lscr.io/linuxserver/lidarr
container_name: lidarr
environment:
- PUID=<your_PUID>
- PGID=<your_PGID>
- PUID=${PUID}
- PGID=${PGID}
volumes:
- <media_folder>/music:/music
- <media_folder>/downloads:/downloads
- <install_location>/config/lidarr:/config
- ${MEDIA_DIRECTORY}/music:/music
- ${MEDIA_DIRECTORY}/downloads:/downloads
- ${INSTALL_LOCATION}/config/lidarr:/config
ports:
- 8686:8686
restart: unless-stopped
@ -88,12 +88,12 @@ services:
image: lscr.io/linuxserver/readarr:develop
container_name: readarr
environment:
- PUID=<your_PUID>
- PGID=<your_PGID>
- PUID=${PUID}
- PGID=${PGID}
volumes:
- <media_folder>/books:/books
- <media_folder>/downloads:/downloads
- <install_location>/config/readarr:/config
- ${MEDIA_DIRECTORY}/books:/books
- ${MEDIA_DIRECTORY}/downloads:/downloads
- ${INSTALL_LOCATION}/config/readarr:/config
ports:
- 8787:8787
restart: unless-stopped
@ -104,12 +104,12 @@ services:
image: lscr.io/linuxserver/bazarr
container_name: bazarr
environment:
- PUID=<your_PUID>
- PGID=<your_PGID>
- PUID=${PUID}
- PGID=${PGID}
volumes:
- <media_folder>/movies:/movies
- <media_folder>/tvshows:/tv
- <install_location>/config/bazarr:/config
- ${MEDIA_DIRECTORY}/movies:/movies
- ${MEDIA_DIRECTORY}/tvshows:/tv
- ${INSTALL_LOCATION}/config/bazarr:/config
ports:
- 6767:6767
restart: unless-stopped
@ -120,10 +120,10 @@ services:
image: lscr.io/linuxserver/prowlarr
container_name: prowlarr
environment:
- PUID=<your_PUID>
- PGID=<your_PGID>
- PUID=${PUID}
- PGID=${PGID}
volumes:
- <install_location>/config/prowlarr:/config
- ${INSTALL_LOCATION}/config/prowlarr:/config
ports:
- 9696:9696
restart: unless-stopped
@ -142,13 +142,12 @@ services:
- 8388:8388/udp # Shadowsocks
#- 8080:8080/tcp # gluetun
volumes:
- <install_location>/config/gluetun:/config
- ${INSTALL_LOCATION}/config/gluetun:/config
environment:
- VPN_SERVICE_PROVIDER=<vpn_service>
- VPN_SERVICE_PROVIDER=${VPN_SERVICE}
- VPN_TYPE=openvpn
- OPENVPN_USER=<vpn_user>
- OPENVPN_PASSWORD=<vpn_password>
- SERVER_COUNTRIES=<vpn_country>
- OPENVPN_USER=${VPN_USER}
- OPENVPN_PASSWORD=${VPN_PASSWORD}
- OPENVPN_CIPHERS=AES-256-GCM
restart: unless-stopped
@ -161,7 +160,7 @@ services:
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- <install_location>/config/portainer:/data
- ${INSTALL_LOCATION}/config/portainer:/data
restart: unless-stopped
# Watchtower is going to keep our instances updated

530
docs.org Normal file
View File

@ -0,0 +1,530 @@
#+title: Docs
#+PROPERTY: header-args :tangle setup.sh
#+auto_tangle: t
* Table of contents :toc:
:PROPERTIES:
:ID: faf95c8a-9133-4072-8544-0ef456a67611
:END:
- [[#welcome-message][Welcome message]]
- [[#functions][Functions]]
- [[#message-formatting][Message formatting]]
- [[#check-the-dependencies][Check the dependencies]]
- [[#running-services-location][Running services location]]
- [[#verify-all-the-dependencies][Verify all the dependencies]]
- [[#gather-all-the-required-information][Gather all the required information]]
- [[#checking-install-location][Checking install location]]
- [[#setting-the-correct-user][Setting the correct user]]
- [[#media-directory][Media directory]]
- [[#setting-perferred-media-service][Setting perferred media service]]
- [[#setting-the-vpn][Setting the VPN]]
- [[#installing-yams][Installing YAMS]]
- [[#copy-the-docker-compose-file-to-the-install-location][Copy the docker-compose file to the install location]]
- [[#set-puid-pgid-media-folder-media-service-config-folder-and-vpn-on-the-yams-scripts][Set PUID, PGID, Media Folder, Media Service, Config folder and VPN on the YAMS scripts]]
- [[#set-the-configuration-for-the-yams-binary][Set the configuration for the YAMS binary]]
- [[#success-message][Success message!]]
- [[#final-steps][Final steps]]
- [[#install-the-yams-cli][Install the YAMS CLI]]
- [[#set-the-correct-permissions-to-the-media-and-install-directories][Set the correct permissions to the media and install directories]]
- [[#create-the-config-directory][Create the config directory]]
- [[#display-closing-message][Display closing message]]
* Welcome message
:PROPERTIES:
:ID: 525c03eb-cab9-44f8-8cc5-e5ec9035a938
:END:
This is just a welcome message for the script
#+begin_src bash
#!/bin/bash
set -euo pipefail
printf "\033c"
echo "===================================================="
echo " ___ ___ ___ "
echo " ___ / /\ /__/\ / /\ "
echo " /__/| / /::\ | |::\ / /:/_ "
echo " | |:| / /:/\:\ | |:|:\ / /:/ /\ "
echo " | |:| / /:/~/::\ __|__|:|\:\ / /:/ /::\\"
echo " __|__|:| /__/:/ /:/\:\ /__/::::| \:\ /__/:/ /:/\:\\"
echo "/__/::::\ \ \:\/:/__\/ \ \:\~~\__\/ \ \:\/:/~/:/"
echo " ~\~~\:\ \ \::/ \ \:\ \ \::/ /:/ "
echo " \ \:\ \ \:\ \ \:\ \__\/ /:/ "
echo " \__\/ \ \:\ \ \:\ /__/:/ "
echo " \__\/ \__\/ \__\/ "
echo "===================================================="
echo "Welcome to YAMS (Yet Another Media Server)"
echo "Installation process should be really quick"
echo "We just need you to answer some questions"
echo "We are going to ask for your sudo password in the end"
echo "To finish the installation of the CLI"
echo "===================================================="
echo ""
#+end_src
* Functions
:PROPERTIES:
:ID: 111a7df4-08f5-4e6c-a799-dd822c5d030e
:END:
To make development easier, we declare some functions that are going to be used a lot later
** Message formatting
:PROPERTIES:
:ID: 61387bd4-2ecf-44fe-ac69-dc6347c0d1b8
:END:
Both of these functions format the message in different colors, depending on what the message means
*** Success
:PROPERTIES:
:ID: ec8f113c-43f9-4585-a1b5-8c7ec4e84bb2
:END:
#+begin_src bash
send_success_message() {
echo -e $(printf "\e[32m$1\e[0m")
}
#+end_src
*** Error
:PROPERTIES:
:ID: 1a6cd951-c9ce-46fc-8953-f5e206f7cd23
:END:
Error is basically the same as before, but it ~exit 255~ to finish the execution.
#+begin_src bash
send_error_message() {
echo -e $(printf "\e[31m$1\e[0m")
exit 255
}
#+end_src
** Check the dependencies
:PROPERTIES:
:ID: e7d01eeb-c7ef-42ff-b60d-010be30bc6a8
:END:
This function verifies that the dependencies are installed. ~Docker~ and ~docker-compose~ are required
for YAMS to work.
#+begin_src bash
check_dependencides() {
if command -v "$1" &> /dev/null; then
send_success_message "$1 exists ✅ "
else
echo -e $(printf "\e[31m ⚠️ $1 not found! ⚠️\e[0m")
read -p "Do you want YAMS to install docker and docker-compose? IT ONLY WORKS ON DEBIAN AND UBUNTU! [y/N]: " install_docker
install_docker=${install_docker:-"n"}
if [ "$install_docker" == "y" ]; then
bash ./docker.sh
else
send_error_message "Install docker and docker-compose and come back later!"
fi
fi
}
#+end_src
** Running services location
:PROPERTIES:
:ID: 53213557-edfe-4da7-88c0-e0e202429116
:END:
This function just displays the locations for every container so the user can access to it when YAMS
finish installing.
#+begin_src bash
running_services_location() {
host_ip=$(hostname -I | awk '{ print $1 }')
services=(
"qBittorrent:8080"
"Radarr:7878"
"Sonarr:8989"
"Lidarr:8686"
"Readarr:8787"
"Prowlarr:9696"
"Bazarr:6767"
"$media_service:$media_service_port"
"Portainer:9000"
)
echo -e "Service URLs:"
for service in "${services[@]}"; do
service_name="${service%%:*}"
service_port="${service##*:}"
echo "$service_name: http://$host_ip:$service_port/"
done
}
#+end_src
* Verify all the dependencies
:PROPERTIES:
:ID: e945d5a8-5142-41fe-8175-96de7aa84cf2
:END:
#+begin_src bash
echo "Checking prerequisites..."
check_dependencides "docker"
check_dependencides "docker-compose"
if [[ "$EUID" = 0 ]]; then
send_error_message "YAMS has to run without sudo! Please, run it again with regular permissions"
fi
#+end_src
* Gather all the required information
:PROPERTIES:
:ID: 438cecef-2bd6-4d7c-b429-6c674ae311d9
:END:
** Checking install location
:PROPERTIES:
:ID: fff12355-9d79-40fe-a540-cfba2a176a3e
:END:
#+begin_src bash
default_install_directory="/opt/yams"
read -p "Where do you want to install the docker-compose file? [$default_install_directory]: " install_directory
install_directory=${install_directory:-$default_install_directory}
if [ ! -d "$install_directory" ]; then
echo "The directory \"$install_directory\" does not exists. Attempting to create..."
if mkdir -p "$install_directory"; then
send_success_message "Directory $install_directory created ✅"
else
send_error_message "There was an error creating the installation directory at \"$install_directory\". Make sure you have the necessary permissions ❌"
fi
fi
filename="$install_directory/docker-compose.yaml"
custom_file_filename="$install_directory/docker-compose.custom.yaml"
env_file="$install_directory/.env"
#+end_src
** Setting the correct user
:PROPERTIES:
:ID: 7428d7b7-aec5-4638-b370-84e9055fb412
:END:
#+begin_src bash
read -p "What's the user that is going to own the media server files? [$USER]: " username
username=${username:-$USER}
if id -u "$username" &>/dev/null; then
puid=$(id -u "$username");
pgid=$(id -g "$username");
else
send_error_message "The user \"$username\" doesn't exist!"
fi
#+end_src
** Media directory
:PROPERTIES:
:ID: 9726dead-8833-4f23-98b8-2790d72605de
:END:
#+begin_src bash
read -p "Please, input your media directory [/srv/media]: " media_directory
media_directory=${media_directory:-"/srv/media"}
read -p "Are you sure your media directory is \"$media_directory\"? [y/N]: " media_directory_correct
media_directory_correct=${media_directory_correct:-"n"}
if [ ! -d "$media_directory" ]; then
echo "The directory \"$media_directory\" does not exists. Attempting to create..."
if mkdir -p "$media_directory"; then
send_success_message "Directory $media_directory created ✅"
else
send_error_message "There was an error creating the installation directory at \"$media_directory\". Make sure you have the necessary permissions ❌"
fi
fi
if [ "$media_directory_correct" == "n" ]; then
send_error_message "Media directory is not correct. Please fix it and run the script again ❌"
fi
#+end_src
** Setting perferred media service
:PROPERTIES:
:ID: 3af8dbed-3a88-4739-a721-6434993c0b67
:END:
#+begin_src bash
echo -e "\n\n\nTime to choose your media service."
echo "Your media service is responsible for serving your files to your network."
echo "By default, YAMS supports 3 media services:"
echo "- jellyfin (recommended, easier)"
echo "- emby"
echo "- plex (advanced, always online)"
read -p "Choose your media service [jellyfin]: " media_service
media_service=${media_service:-"jellyfin"}
media_service=$(echo "$media_service" | awk '{print tolower($0)}')
media_service_port=8096
if [ "$media_service" == "plex" ]; then
media_service_port=32400
fi
if echo "emby plex jellyfin" | grep -qw "$media_service"; then
echo -e "\nYAMS is going to install \"$media_service\" on port \"$media_service_port\""
else
send_error_message "\"$media_service\" is not supported by YAMS. Are you sure you chose the correct service?"
fi
#+end_src
** Setting the VPN
:PROPERTIES:
:ID: 1da4fe67-ee20-4b70-8f36-4a9f7161b6ca
:END:
#+begin_src bash
echo -e "\nTime to set up the VPN."
echo "You can check the supported VPN list here: https://yams.media/advanced/vpn."
read -p "Do you want to configure a VPN? [Y/n]: " setup_vpn
setup_vpn=${setup_vpn:-"y"}
if [ "$setup_vpn" == "y" ]; then
read -p "What's your VPN service? (with spaces) [mullvad]: " vpn_service
vpn_service=${vpn_service:-"mullvad"}
echo -e "\nYou should read $vpn_service's documentation in case it has different configurations for username and password."
echo "The documentation for $vpn_service is here: https://github.com/qdm12/gluetun-wiki/blob/main/setup/providers/${vpn_service// /-}.md"
read -p "What's your VPN username? (without spaces): " vpn_user
unset vpn_password
charcount=0
prompt="What's your VPN password? (if you are using mullvad, just enter your username again): "
while IFS= read -p "$prompt" -r -s -n 1 char
do
if [[ $char == $'\0' ]]
then
break
fi
if [[ $char == $'\177' ]] ; then
if [ $charcount -gt 0 ] ; then
charcount=$((charcount-1))
prompt=$'\b \b'
vpn_password="${vpn_password%?}"
else
prompt=''
fi
else
charcount=$((charcount+1))
prompt='*'
vpn_password+="$char"
fi
done
echo
fi
echo "Configuring the docker-compose file for the user \"$username\" on \"$install_directory\"..."
#+end_src
* Installing YAMS
:PROPERTIES:
:ID: 44e5f3f1-3ae7-4f88-ba96-8149c9980fb2
:END:
** Copy the docker-compose file to the install location
:PROPERTIES:
:ID: 09018e25-ed48-46e9-85c3-586c37844c11
:END:
#+begin_src bash
copy_files=(
"docker-compose.example.yaml:$filename"
".env.example:$env_file"
"docker-compose.custom.yaml:$custom_file_filename"
)
for file_mapping in "${copy_files[@]}"; do
source_file="${file_mapping%%:*}"
destination_file="${file_mapping##*:}"
echo -e "\nCopying $source_file to $destination_file..."
if cp "$source_file" "$destination_file"; then
send_success_message "$source_file was copied successfuly! ✅"
else
send_error_message "Failed to copy $source_file to $destination_file. Ensure your user ($USER) has the necessary permissions ❌"
fi
done
#+end_src
#+RESULTS:
** Set PUID, PGID, Media Folder, Media Service, Config folder and VPN on the YAMS scripts
:PROPERTIES:
:ID: 3d169001-f0f7-477f-a954-0460484f4b43
:END:
This steps prepares all the files with the correct information that was collected on the "[[#gather-all-the-required-information][Gather all the
required information]]" step.
#+begin_src bash
sed -i -e "s|<your_PUID>|$puid|g" "$env_file" \
-e "s|<your_PGID>|$pgid|g" "$env_file" \
-e "s|<media_directory>|$media_directory|g" "$env_file" \
-e "s|<media_service>|$media_service|g" "$env_file" \
-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
sed -i -e "s|<install_directory>|$install_directory|g" "$env_file"
if [ "$setup_vpn" == "y" ]; then
sed -i -e "s|<vpn_service>|$vpn_service|g" "$env_file" \
-e "s|<vpn_user>|$vpn_user|g" "$env_file" \
-e "s|<vpn_password>|$vpn_password|g" "$env_file" \
-e "s|<vpn_enabled>|$setup_vpn|g" "$env_file" \
-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
#+end_src
** Set the configuration for the YAMS binary
:PROPERTIES:
:ID: b6a8732f-9dbe-4d93-b04d-27156eacdea2
:END:
#+begin_src bash
sed -i -e "s|<filename>|$filename|g" yams \
-e "s|<custom_file_filename>|$custom_file_filename|g" yams \
-e "s|<install_directory>|$install_directory|g" yams
#+end_src
** Success message!
:PROPERTIES:
:ID: 7b0ed8f5-780b-4685-8123-8d5c4229eaba
:END:
Finally, YAMS is installed 🔥. Show the success message
#+begin_src bash
send_success_message "Everything installed correctly! 🎉"
echo "Running the server..."
echo "This is going to take a while..."
docker-compose -f "$filename" up -d
#+end_src
* Final steps
:PROPERTIES:
:ID: 65ce5828-b69a-4a0e-83f6-b029e19caea1
:END:
** Install the YAMS CLI
:PROPERTIES:
:ID: f4f9d166-8a2b-4d79-bc7f-fe73ecf5fb77
:END:
This steps requires ~sudo~ because it's copying the main yams script to the ~/usr/local/bin/yams~
directory.
#+begin_src bash
echo -e "\nWe need your sudo password to install the YAMS CLI and configure permissions..."
if sudo cp yams /usr/local/bin/yams && sudo chmod +x /usr/local/bin/yams; then
send_success_message "YAMS CLI installed successfully ✅"
else
send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions ❌"
fi
#+end_src
** Set the correct permissions to the media and install directories
:PROPERTIES:
:ID: 4cfb9397-776d-46db-84cc-54b78395cba8
:END:
This adds the correct permissions to the media folder, in case they are not correct.
#+begin_src bash
if sudo chown -R "$puid":"$pgid" "$media_directory"; then
send_success_message "Media directory ownership and permissions set successfully ✅"
else
send_error_message "Failed to set ownership and permissions for the media directory. Check permissions ❌"
fi
if sudo chown -R "$puid":"$pgid" "$install_directory"; then
send_success_message "Install directory ownership and permissions set successfully ✅"
else
send_error_message "Failed to set ownership and permissions for the install directory. Check permissions ❌"
fi
#+end_src
** Create the config directory
:PROPERTIES:
:ID: 699f35fe-edde-406d-be0b-3ff2eaa6d7eb
:END:
This is where all the configurations are going to be saved. If it doesn't it will try and create it. If
it can't be created, we'll raise an error.
#+begin_src bash
if [[ -d "$install_directory/config" ]]; then
send_success_message "Configuration folder \"$install_directory/config\" exists ✅"
else
if sudo mkdir -p "$install_directory/config"; then
send_success_message "Configuration folder \"$install_directory/config\" created ✅"
else
send_error_message "Failed to create or access the configuration folder. Check permissions ❌"
fi
fi
if sudo chown -R "$puid":"$pgid" "$install_directory/config"; then
send_success_message "Configuration folder ownership and permissions set successfully ✅"
else
send_error_message "Failed to set ownership and permissions for the configuration folder. Check permissions ❌"
fi
#+end_src
* Display closing message
:PROPERTIES:
:ID: 238e3eae-9df7-4a7f-a460-7a61c07b5442
:END:
#+begin_src bash
printf "\033c"
echo "========================================================"
echo " _____ ___ ___ ___ "
echo " / /::\ / /\ /__/\ / /\ "
echo " / /:/\:\ / /::\ \ \:\ / /:/_ "
echo " / /:/ \:\ / /:/\:\ \ \:\ / /:/ /\ "
echo " /__/:/ \__\:| / /:/ \:\ _____\__\:\ / /:/ /:/_ "
echo " \ \:\ / /:/ /__/:/ \__\:\ /__/::::::::\ /__/:/ /:/ /\\"
echo " \ \:\ /:/ \ \:\ / /:/ \ \:\~~\~~\/ \ \:\/:/ /:/"
echo " \ \:\/:/ \ \:\ /:/ \ \:\ ~~~ \ \::/ /:/ "
echo " \ \::/ \ \:\/:/ \ \:\ \ \:\/:/ "
echo " \__\/ \ \::/ \ \:\ \ \::/ "
echo " \__\/ \__\/ \__\/ "
echo "========================================================"
send_success_message "All done!✅ Enjoy YAMS!"
echo "You can check the installation on $install_directory"
echo "========================================================"
echo "Everything should be running now! To check everything running, go to:"
echo
running_services_location
echo
echo
echo "You might need to wait for a couple of minutes while everything gets up and running"
echo
echo "All the services location are also saved in ~/yams_services.txt"
running_services_location > ~/yams_services.txt
echo "========================================================"
echo
echo "To configure YAMS, check the documentation at"
echo "https://yams.media/config"
echo
echo "========================================================"
exit 0
#+end_src

View File

@ -1,300 +1,5 @@
#!/bin/bash
set -euo pipefail
printf "\033c"
echo "===================================================="
echo " ___ ___ ___ "
echo " ___ / /\ /__/\ / /\ "
echo " /__/| / /::\ | |::\ / /:/_ "
echo " | |:| / /:/\:\ | |:|:\ / /:/ /\ "
echo " | |:| / /:/~/::\ __|__|:|\:\ / /:/ /::\\"
echo " __|__|:| /__/:/ /:/\:\ /__/::::| \:\ /__/:/ /:/\:\\"
echo "/__/::::\ \ \:\/:/__\/ \ \:\~~\__\/ \ \:\/:/~/:/"
echo " ~\~~\:\ \ \::/ \ \:\ \ \::/ /:/ "
echo " \ \:\ \ \:\ \ \:\ \__\/ /:/ "
echo " \__\/ \ \:\ \ \:\ /__/:/ "
echo " \__\/ \__\/ \__\/ "
echo "===================================================="
echo "Welcome to YAMS (Yet Another Media Server)"
echo "Installation process should be really quick"
echo "We just need you to answer some questions"
echo "We are going to ask for your sudo password in the end"
echo "To finish the installation of the CLI"
echo "===================================================="
echo ""
# ============================================================================================
# Functions to ease development
# ============================================================================================
send_success_message() {
echo -e $(printf "\e[32m$1\e[0m")
}
send_error_message() {
echo -e $(printf "\e[31m$1\e[0m")
exit 255
}
check_dependencides() {
if command -v $1 &> /dev/null; then
send_success_message "$1 exists ✅ "
else
echo -e $(printf "\e[31m ⚠️ $1 not found! ⚠️\e[0m")
read -p "Do you want YAMS to install docker and docker-compose? IT ONLY WORKS ON DEBIAN AND UBUNTU! [y/N]: " install_docker
install_docker=${install_docker:-"n"}
if [ "$install_docker" == "y" ]; then
bash ./docker.sh
else
send_error_message "Install docker and docker-compose and come back later!"
fi
fi
}
running_services_location() {
host_ip=$(hostname -I | awk '{ print $1 }')
echo "qBittorrent: http://$host_ip:8080/"
echo "Radarr: http://$host_ip:7878/"
echo "Sonarr: http://$host_ip:8989/"
echo "Lidarr: http://$host_ip:8686/"
echo "Readarr: http://$host_ip:8787/"
echo "Prowlarr: http://$host_ip:9696/"
echo "Bazarr: http://$host_ip:6767/"
echo "$media_service: http://$host_ip:$media_service_port/"
echo "Portainer: http://$host_ip:9000/"
}
# ============================================================================================
# Check all the prerequisites are installed before continuing
# ============================================================================================
echo "Checking prerequisites..."
check_dependencides "docker"
check_dependencides "docker-compose"
if [[ "$EUID" = 0 ]]; then
send_error_message "YAMS has to run without sudo! Please, run it again with regular permissions"
fi
# ============================================================================================
# ============================================================================================
# Gathering information
# ============================================================================================
read -p "Where do you want to install the docker-compose file? [/opt/yams]: " install_location
# Checking if the install_location exists
install_location=${install_location:-/opt/yams}
[[ -f "$install_location" ]] || mkdir -p "$install_location" || send_error_message "There was an error with your install location! Make sure the directory exists and the user \"$USER\" has permissions on it"
install_location=$(realpath "$install_location")
filename="$install_location/docker-compose.yaml"
read -p "What's the user that is going to own the media server files? [$USER]: " username
# Checking that the user exists
username=${username:-$USER}
if id -u "$username" &>/dev/null; then
puid=$(id -u "$username");
pgid=$(id -g "$username");
else
send_error_message "The user \"$username\" doesn't exist!"
fi
read -p "Please, input your media folder [/srv/media]: " media_folder
media_folder=${media_folder:-"/srv/media"}
# Checking that the media folder exists
realpath "$media_folder" &>/dev/null || send_error_message "There was an error with your media folder! The directory \"$media_folder\" does not exist!"
media_folder=$(realpath "$media_folder")
read -p "Are you sure your media folder is \"$media_folder\"? [y/N]: " media_folder_correct
media_folder_correct=${media_folder_correct:-"n"}
if [ "$media_folder_correct" == "n" ]; then
send_error_message "Media folder is not correct. Please, fix it and run the script again"
fi
# Setting the preferred media service
echo
echo
echo
echo "Time to choose your media service."
echo "Your media service is the one responsible for serving your files to your network."
echo "By default, YAMS support 3 media services:"
echo "- jellyfin (recommended, easier)"
echo "- emby"
echo "- plex (advanced, always online)"
read -p "Choose your media service [jellyfin]: " media_service
media_service=${media_service:-"jellyfin"}
media_service=$(echo "$media_service" | sed -e 's/\(.*\)/\L\1/')
media_service_port=8096
if [ "$media_service" == "plex" ]; then
media_service_port=32400
fi
if echo "emby plex jellyfin" | grep -qw "$media_service"; then
echo "YAMS is going to install \"$media_service\" on port \"$media_service_port\""
else
send_error_message "\"$media_service\" is not supported by YAMS. Are you sure you chose the correct service?"
fi
# Adding the VPN
echo
echo
echo
echo "Time to set up the VPN."
echo "You can check the supported VPN list here: https://yams.media/advanced/vpn."
read -p "Do you want to configure a VPN? [Y/n]: " setup_vpn
setup_vpn=${setup_vpn:-"y"}
if [ "$setup_vpn" == "y" ]; then
read -p "What's your VPN service? (with spaces) [mullvad]: " vpn_service
vpn_service=${vpn_service:-"mullvad"}
echo
echo "You should read $vpn_service's documentation in case it has different configurations for username and password."
echo "The documentation for $vpn_service is here: https://github.com/qdm12/gluetun-wiki/blob/main/setup/providers/${vpn_service// /-}.md"
echo
read -p "What's your VPN username? (without spaces): " vpn_user
unset vpn_password
charcount=0
prompt="What's your VPN password? (if you are using mullvad, just enter your username again): "
while IFS= read -p "$prompt" -r -s -n 1 char
do
if [[ $char == $'\0' ]]
then
break
fi
if [[ $char == $'\177' ]] ; then
if [ $charcount -gt 0 ] ; then
charcount=$((charcount-1))
prompt=$'\b \b'
vpn_password="${vpn_password%?}"
else
prompt=''
fi
else
charcount=$((charcount+1))
prompt='*'
vpn_password+="$char"
fi
done
echo
echo "What country do you want to use?"
echo "If you are using: NordVPN, Perfect Privacy, Private Internet Access, VyprVPN, WeVPN or Windscribe, then input a region"
read -p "You can check the countries/regions list for your VPN here: https://github.com/qdm12/gluetun/wiki/$vpn_service#servers [brazil]: " vpn_country
vpn_country=${vpn_country:-"brazil"}
fi
echo "Configuring the docker-compose file for the user \"$username\" on \"$install_location\"..."
# ============================================================================================
# ============================================================================================
# Actually installing everything!
# ============================================================================================
# Copy the docker-compose file from the example to the real one
echo ""
echo "Copying $filename..."
cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!"
# Set PUID
sed -i -e "s/<your_PUID>/$puid/g" "$filename"
# Set PGID
sed -i -e "s/<your_PGID>/$pgid/g" "$filename"
# Set media_folder
sed -i -e "s;<media_folder>;$media_folder;g" "$filename"
# Set media_service
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
# Set config folder
sed -i -e "s;<install_location>;$install_location;g" "$filename"
# Set VPN
if [ "$setup_vpn" == "y" ]; then
sed -i -e "s;<vpn_service>;$vpn_service;g" "$filename"
sed -i -e "s;<vpn_user>;$vpn_user;g" "$filename"
sed -i -e "s;<vpn_country>;$vpn_country;g" "$filename"
sed -i -e "s;<vpn_password>;$vpn_password;g" "$filename"
sed -i -e "s;#network_mode: \"service:gluetun\";network_mode: \"service:gluetun\";g" "$filename"
sed -i -e "s;ports: # qbittorrent;#port: # qbittorrent;g" "$filename"
sed -i -e "s;- 8080:8080 # qbittorrent;#- 8080:8080 # qbittorrent;g" "$filename"
sed -i -e "s;#- 8080:8080/tcp # gluetun;- 8080:8080/tcp # gluetun;g" "$filename"
if echo "nordvpn perfect privacy private internet access vyprvpn wevpn windscribe" | grep -qw "$vpn_service"; then
sed -i -e "s;SERVER_COUNTRIES;SERVER_REGIONS;g" "$filename"
fi
fi
# Set yams script
sed -i -e "s;<filename>;$filename;g" yams
sed -i -e "s;<install_location>;$install_location;g" yams
send_success_message "Everything installed correctly! 🎉"
echo "Running the server..."
echo "This is going to take a while..."
docker-compose -f "$filename" up -d
# ============================================================================================
# ============================================================================================
# Cleaning up...
# ============================================================================================
send_success_message "We need your sudo password to install the yams CLI and correct permissions..."
sudo cp yams /usr/local/bin/yams && sudo chmod +x /usr/local/bin/yams
[[ -f "$media_folder" ]] || sudo mkdir -p "$media_folder" || send_error_message "There was an error with your install location!"
sudo chown -R "$puid":"$pgid" "$media_folder"
[[ -f $install_location/config ]] || sudo mkdir -p "$install_location/config"
sudo chown -R "$puid":"$pgid" "$install_location"
printf "\033c"
echo "========================================================"
echo " _____ ___ ___ ___ "
echo " / /::\ / /\ /__/\ / /\ "
echo " / /:/\:\ / /::\ \ \:\ / /:/_ "
echo " / /:/ \:\ / /:/\:\ \ \:\ / /:/ /\ "
echo " /__/:/ \__\:| / /:/ \:\ _____\__\:\ / /:/ /:/_ "
echo " \ \:\ / /:/ /__/:/ \__\:\ /__/::::::::\ /__/:/ /:/ /\\"
echo " \ \:\ /:/ \ \:\ / /:/ \ \:\~~\~~\/ \ \:\/:/ /:/"
echo " \ \:\/:/ \ \:\ /:/ \ \:\ ~~~ \ \::/ /:/ "
echo " \ \::/ \ \:\/:/ \ \:\ \ \:\/:/ "
echo " \__\/ \ \::/ \ \:\ \ \::/ "
echo " \__\/ \__\/ \__\/ "
echo "========================================================"
send_success_message "All done!✅ Enjoy YAMS!"
echo "You can check the installation on $install_location"
echo "========================================================"
echo "Everything should be running now! To check everything running, go to:"
echo
running_services_location
echo
echo
echo "You might need to wait for a couple of minutes while everything gets up and running"
echo
echo "All the services location are also saved in ~/yams_services.txt"
running_services_location > ~/yams_services.txt
echo "========================================================"
echo
echo "To configure YAMS, check the documentation at"
echo "https://yams.media/config"
echo
echo "========================================================"
exit 0
# ============================================================================================
git clone https://gitlab.com/rogs/yams.git --depth=1 /tmp/yams > /dev/null 2>&1
bash /tmp/yams/install.sh
rm -rf /tmp/yams

317
setup.sh Normal file
View File

@ -0,0 +1,317 @@
#!/bin/bash
set -euo pipefail
printf "\033c"
echo "===================================================="
echo " ___ ___ ___ "
echo " ___ / /\ /__/\ / /\ "
echo " /__/| / /::\ | |::\ / /:/_ "
echo " | |:| / /:/\:\ | |:|:\ / /:/ /\ "
echo " | |:| / /:/~/::\ __|__|:|\:\ / /:/ /::\\"
echo " __|__|:| /__/:/ /:/\:\ /__/::::| \:\ /__/:/ /:/\:\\"
echo "/__/::::\ \ \:\/:/__\/ \ \:\~~\__\/ \ \:\/:/~/:/"
echo " ~\~~\:\ \ \::/ \ \:\ \ \::/ /:/ "
echo " \ \:\ \ \:\ \ \:\ \__\/ /:/ "
echo " \__\/ \ \:\ \ \:\ /__/:/ "
echo " \__\/ \__\/ \__\/ "
echo "===================================================="
echo "Welcome to YAMS (Yet Another Media Server)"
echo "Installation process should be really quick"
echo "We just need you to answer some questions"
echo "We are going to ask for your sudo password in the end"
echo "To finish the installation of the CLI"
echo "===================================================="
echo ""
send_success_message() {
echo -e $(printf "\e[32m$1\e[0m")
}
send_error_message() {
echo -e $(printf "\e[31m$1\e[0m")
exit 255
}
check_dependencides() {
if command -v "$1" &> /dev/null; then
send_success_message "$1 exists ✅ "
else
echo -e $(printf "\e[31m ⚠️ $1 not found! ⚠️\e[0m")
read -p "Do you want YAMS to install docker and docker-compose? IT ONLY WORKS ON DEBIAN AND UBUNTU! [y/N]: " install_docker
install_docker=${install_docker:-"n"}
if [ "$install_docker" == "y" ]; then
bash ./docker.sh
else
send_error_message "Install docker and docker-compose and come back later!"
fi
fi
}
running_services_location() {
host_ip=$(hostname -I | awk '{ print $1 }')
services=(
"qBittorrent:8080"
"Radarr:7878"
"Sonarr:8989"
"Lidarr:8686"
"Readarr:8787"
"Prowlarr:9696"
"Bazarr:6767"
"$media_service:$media_service_port"
"Portainer:9000"
)
echo -e "Service URLs:"
for service in "${services[@]}"; do
service_name="${service%%:*}"
service_port="${service##*:}"
echo "$service_name: http://$host_ip:$service_port/"
done
}
echo "Checking prerequisites..."
check_dependencides "docker"
check_dependencides "docker-compose"
if [[ "$EUID" = 0 ]]; then
send_error_message "YAMS has to run without sudo! Please, run it again with regular permissions"
fi
default_install_directory="/opt/yams"
read -p "Where do you want to install the docker-compose file? [$default_install_directory]: " install_directory
install_directory=${install_directory:-$default_install_directory}
if [ ! -d "$install_directory" ]; then
echo "The directory \"$install_directory\" does not exists. Attempting to create..."
if mkdir -p "$install_directory"; then
send_success_message "Directory $install_directory created ✅"
else
send_error_message "There was an error creating the installation directory at \"$install_directory\". Make sure you have the necessary permissions ❌"
fi
fi
filename="$install_directory/docker-compose.yaml"
custom_file_filename="$install_directory/docker-compose.custom.yaml"
env_file="$install_directory/.env"
read -p "What's the user that is going to own the media server files? [$USER]: " username
username=${username:-$USER}
if id -u "$username" &>/dev/null; then
puid=$(id -u "$username");
pgid=$(id -g "$username");
else
send_error_message "The user \"$username\" doesn't exist!"
fi
read -p "Please, input your media directory [/srv/media]: " media_directory
media_directory=${media_directory:-"/srv/media"}
read -p "Are you sure your media directory is \"$media_directory\"? [y/N]: " media_directory_correct
media_directory_correct=${media_directory_correct:-"n"}
if [ ! -d "$media_directory" ]; then
echo "The directory \"$media_directory\" does not exists. Attempting to create..."
if mkdir -p "$media_directory"; then
send_success_message "Directory $media_directory created ✅"
else
send_error_message "There was an error creating the installation directory at \"$media_directory\". Make sure you have the necessary permissions ❌"
fi
fi
if [ "$media_directory_correct" == "n" ]; then
send_error_message "Media directory is not correct. Please fix it and run the script again ❌"
fi
echo -e "\n\n\nTime to choose your media service."
echo "Your media service is responsible for serving your files to your network."
echo "By default, YAMS supports 3 media services:"
echo "- jellyfin (recommended, easier)"
echo "- emby"
echo "- plex (advanced, always online)"
read -p "Choose your media service [jellyfin]: " media_service
media_service=${media_service:-"jellyfin"}
media_service=$(echo "$media_service" | awk '{print tolower($0)}')
media_service_port=8096
if [ "$media_service" == "plex" ]; then
media_service_port=32400
fi
if echo "emby plex jellyfin" | grep -qw "$media_service"; then
echo -e "\nYAMS is going to install \"$media_service\" on port \"$media_service_port\""
else
send_error_message "\"$media_service\" is not supported by YAMS. Are you sure you chose the correct service?"
fi
echo -e "\nTime to set up the VPN."
echo "You can check the supported VPN list here: https://yams.media/advanced/vpn."
read -p "Do you want to configure a VPN? [Y/n]: " setup_vpn
setup_vpn=${setup_vpn:-"y"}
if [ "$setup_vpn" == "y" ]; then
read -p "What's your VPN service? (with spaces) [mullvad]: " vpn_service
vpn_service=${vpn_service:-"mullvad"}
echo -e "\nYou should read $vpn_service's documentation in case it has different configurations for username and password."
echo "The documentation for $vpn_service is here: https://github.com/qdm12/gluetun-wiki/blob/main/setup/providers/${vpn_service// /-}.md"
read -p "What's your VPN username? (without spaces): " vpn_user
unset vpn_password
charcount=0
prompt="What's your VPN password? (if you are using mullvad, just enter your username again): "
while IFS= read -p "$prompt" -r -s -n 1 char
do
if [[ $char == $'\0' ]]
then
break
fi
if [[ $char == $'\177' ]] ; then
if [ $charcount -gt 0 ] ; then
charcount=$((charcount-1))
prompt=$'\b \b'
vpn_password="${vpn_password%?}"
else
prompt=''
fi
else
charcount=$((charcount+1))
prompt='*'
vpn_password+="$char"
fi
done
echo
fi
echo "Configuring the docker-compose file for the user \"$username\" on \"$install_directory\"..."
copy_files=(
"docker-compose.example.yaml:$filename"
".env.example:$env_file"
"docker-compose.custom.yaml:$custom_file_filename"
)
for file_mapping in "${copy_files[@]}"; do
source_file="${file_mapping%%:*}"
destination_file="${file_mapping##*:}"
echo -e "\nCopying $source_file to $destination_file..."
if cp "$source_file" "$destination_file"; then
send_success_message "$source_file was copied successfuly! ✅"
else
send_error_message "Failed to copy $source_file to $destination_file. Ensure your user ($USER) has the necessary permissions ❌"
fi
done
sed -i -e "s|<your_PUID>|$puid|g" "$env_file" \
-e "s|<your_PGID>|$pgid|g" "$env_file" \
-e "s|<media_directory>|$media_directory|g" "$env_file" \
-e "s|<media_service>|$media_service|g" "$env_file" \
-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
sed -i -e "s|<install_directory>|$install_directory|g" "$env_file"
if [ "$setup_vpn" == "y" ]; then
sed -i -e "s|<vpn_service>|$vpn_service|g" "$env_file" \
-e "s|<vpn_user>|$vpn_user|g" "$env_file" \
-e "s|<vpn_password>|$vpn_password|g" "$env_file" \
-e "s|<vpn_enabled>|$setup_vpn|g" "$env_file" \
-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
sed -i -e "s|<filename>|$filename|g" yams \
-e "s|<custom_file_filename>|$custom_file_filename|g" yams \
-e "s|<install_directory>|$install_directory|g" yams
send_success_message "Everything installed correctly! 🎉"
echo "Running the server..."
echo "This is going to take a while..."
docker-compose -f "$filename" up -d
echo -e "\nWe need your sudo password to install the YAMS CLI and configure permissions..."
if sudo cp yams /usr/local/bin/yams && sudo chmod +x /usr/local/bin/yams; then
send_success_message "YAMS CLI installed successfully ✅"
else
send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions ❌"
fi
if sudo chown -R "$puid":"$pgid" "$media_directory"; then
send_success_message "Media directory ownership and permissions set successfully ✅"
else
send_error_message "Failed to set ownership and permissions for the media directory. Check permissions ❌"
fi
if sudo chown -R "$puid":"$pgid" "$install_directory"; then
send_success_message "Install directory ownership and permissions set successfully ✅"
else
send_error_message "Failed to set ownership and permissions for the install directory. Check permissions ❌"
fi
if [[ -d "$install_directory/config" ]]; then
send_success_message "Configuration folder \"$install_directory/config\" exists ✅"
else
if sudo mkdir -p "$install_directory/config"; then
send_success_message "Configuration folder \"$install_directory/config\" created ✅"
else
send_error_message "Failed to create or access the configuration folder. Check permissions ❌"
fi
fi
if sudo chown -R "$puid":"$pgid" "$install_directory/config"; then
send_success_message "Configuration folder ownership and permissions set successfully ✅"
else
send_error_message "Failed to set ownership and permissions for the configuration folder. Check permissions ❌"
fi
printf "\033c"
echo "========================================================"
echo " _____ ___ ___ ___ "
echo " / /::\ / /\ /__/\ / /\ "
echo " / /:/\:\ / /::\ \ \:\ / /:/_ "
echo " / /:/ \:\ / /:/\:\ \ \:\ / /:/ /\ "
echo " /__/:/ \__\:| / /:/ \:\ _____\__\:\ / /:/ /:/_ "
echo " \ \:\ / /:/ /__/:/ \__\:\ /__/::::::::\ /__/:/ /:/ /\\"
echo " \ \:\ /:/ \ \:\ / /:/ \ \:\~~\~~\/ \ \:\/:/ /:/"
echo " \ \:\/:/ \ \:\ /:/ \ \:\ ~~~ \ \::/ /:/ "
echo " \ \::/ \ \:\/:/ \ \:\ \ \:\/:/ "
echo " \__\/ \ \::/ \ \:\ \ \::/ "
echo " \__\/ \__\/ \__\/ "
echo "========================================================"
send_success_message "All done!✅ Enjoy YAMS!"
echo "You can check the installation on $install_directory"
echo "========================================================"
echo "Everything should be running now! To check everything running, go to:"
echo
running_services_location
echo
echo
echo "You might need to wait for a couple of minutes while everything gets up and running"
echo
echo "All the services location are also saved in ~/yams_services.txt"
running_services_location > ~/yams_services.txt
echo "========================================================"
echo
echo "To configure YAMS, check the documentation at"
echo "https://yams.media/config"
echo
echo "========================================================"
exit 0

52
yams
View File

@ -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