From fdc17536f4a0879a7ad7d42f64cf2b3180abccb8 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Thu, 19 Oct 2023 17:52:51 -0300 Subject: Removed all the gluetun countries configuration --- docker-compose.example.yaml | 1 - install.sh | 9 --------- 2 files changed, 10 deletions(-) diff --git a/docker-compose.example.yaml b/docker-compose.example.yaml index 0f2c82a..5605e37 100644 --- a/docker-compose.example.yaml +++ b/docker-compose.example.yaml @@ -148,7 +148,6 @@ services: - VPN_TYPE=openvpn - OPENVPN_USER= - OPENVPN_PASSWORD= - - SERVER_COUNTRIES= - OPENVPN_CIPHERS=AES-256-GCM restart: unless-stopped diff --git a/install.sh b/install.sh index 2a14084..556d697 100755 --- a/install.sh +++ b/install.sh @@ -186,11 +186,6 @@ if [ "$setup_vpn" == "y" ]; then 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\"..." @@ -228,15 +223,11 @@ sed -i -e "s;;$install_location;g" "$filename" if [ "$setup_vpn" == "y" ]; then sed -i -e "s;;$vpn_service;g" "$filename" sed -i -e "s;;$vpn_user;g" "$filename" - sed -i -e "s;;$vpn_country;g" "$filename" sed -i -e "s;;$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 -- cgit v1.2.3 From f5c161dce195cf0b951977d70f6c15c29ff5c834 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 15:09:40 -0300 Subject: First iteration for literate config --- docs.org | 444 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ install_new.sh | 268 ++++++++++++++++++++++++++++++++++ 2 files changed, 712 insertions(+) create mode 100644 docs.org create mode 100644 install_new.sh diff --git a/docs.org b/docs.org new file mode 100644 index 0000000..ab71780 --- /dev/null +++ b/docs.org @@ -0,0 +1,444 @@ +#+title: Docs +#+PROPERTY: header-args :tangle install_new.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]] + - [[#verify-media-folder][Verify media folder]] + - [[#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][Set PUID, PGID, Media Folder, Media Service, Config folder and VPN]] + - [[#set-the-configuration-for-the-yams-binary][Set the configuration for the YAMS binary]] + - [[#success-message][Success message!]] +- [[#clean-up][Clean up]] + - [[#install-the-yams-cli][Install the YAMS CLI]] +- [[#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 }') + 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/" +} +#+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 +read -p "Where do you want to install the docker-compose file? [/opt/yams]: " install_location + +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 + +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"} +#+end_src + +** Verify media folder +:PROPERTIES: +:ID: 9726dead-8833-4f23-98b8-2790d72605de +:END: + +#+begin_src bash +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 +#+end_src + +** Setting perferred media service +:PROPERTIES: +:ID: 3af8dbed-3a88-4739-a721-6434993c0b67 +:END: + +#+begin_src bash +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 +#+end_src + +** Setting the VPN +:PROPERTIES: +:ID: 1da4fe67-ee20-4b70-8f36-4a9f7161b6ca +:END: + +#+begin_src bash +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\"..." +#+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 +echo "" +echo "Copying $filename..." + +cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" +#+end_src + +** Set PUID, PGID, Media Folder, Media Service, Config folder and VPN +:PROPERTIES: +:ID: 3d169001-f0f7-477f-a954-0460484f4b43 +:END: + +#+begin_src bash +# Set PUID +sed -i -e "s//$puid/g" "$filename" + +# Set PGID +sed -i -e "s//$pgid/g" "$filename" + +# Set media_folder +sed -i -e "s;;$media_folder;g" "$filename" + +# Set media_service +sed -i -e "s;;$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;g" "$filename" + +# Set VPN +if [ "$setup_vpn" == "y" ]; then + sed -i -e "s;;$vpn_service;g" "$filename" + sed -i -e "s;;$vpn_user;g" "$filename" + sed -i -e "s;;$vpn_country;g" "$filename" + sed -i -e "s;;$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 +#+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;g" yams +sed -i -e "s;;$install_location;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 +* Clean up +:PROPERTIES: +:ID: 65ce5828-b69a-4a0e-83f6-b029e19caea1 +:END: +** Install the YAMS CLI +:PROPERTIES: +:ID: f4f9d166-8a2b-4d79-bc7f-fe73ecf5fb77 +:END: + +#+begin_src bash +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" +#+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_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 +#+end_src diff --git a/install_new.sh b/install_new.sh new file mode 100644 index 0000000..e6b0b08 --- /dev/null +++ b/install_new.sh @@ -0,0 +1,268 @@ +#!/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 }') + 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/" +} + +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 + +read -p "Where do you want to install the docker-compose file? [/opt/yams]: " install_location + +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 + +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"} + +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 + +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 + +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\"..." + +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//$puid/g" "$filename" + +# Set PGID +sed -i -e "s//$pgid/g" "$filename" + +# Set media_folder +sed -i -e "s;;$media_folder;g" "$filename" + +# Set media_service +sed -i -e "s;;$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;g" "$filename" + +# Set VPN +if [ "$setup_vpn" == "y" ]; then + sed -i -e "s;;$vpn_service;g" "$filename" + sed -i -e "s;;$vpn_user;g" "$filename" + sed -i -e "s;;$vpn_country;g" "$filename" + sed -i -e "s;;$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 + +sed -i -e "s;;$filename;g" yams +sed -i -e "s;;$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 + +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 -- cgit v1.2.3 From bc03b726ff90f21fb9633ba9cf1629c038f7b74a Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 15:12:15 -0300 Subject: Finished transition to literate --- docs.org | 2 +- install.sh | 32 ------- install_new.sh | 268 --------------------------------------------------------- 3 files changed, 1 insertion(+), 301 deletions(-) mode change 100755 => 100644 install.sh delete mode 100644 install_new.sh diff --git a/docs.org b/docs.org index ab71780..fcac196 100644 --- a/docs.org +++ b/docs.org @@ -1,5 +1,5 @@ #+title: Docs -#+PROPERTY: header-args :tangle install_new.sh +#+PROPERTY: header-args :tangle install.sh #+auto_tangle: t * Table of contents :toc: diff --git a/install.sh b/install.sh old mode 100755 new mode 100644 index 2a14084..e6b0b08 --- a/install.sh +++ b/install.sh @@ -23,10 +23,6 @@ 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") } @@ -65,9 +61,6 @@ running_services_location() { echo "Portainer: http://$host_ip:9000/" } -# ============================================================================================ -# Check all the prerequisites are installed before continuing -# ============================================================================================ echo "Checking prerequisites..." @@ -78,14 +71,8 @@ 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") @@ -93,7 +80,6 @@ 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 @@ -106,8 +92,6 @@ 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") @@ -119,7 +103,6 @@ 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 @@ -144,7 +127,6 @@ 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 @@ -194,13 +176,7 @@ if [ "$setup_vpn" == "y" ]; then 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..." @@ -239,22 +215,15 @@ if [ "$setup_vpn" == "y" ]; then fi fi -# Set yams script sed -i -e "s;;$filename;g" yams sed -i -e "s;;$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 @@ -297,4 +266,3 @@ echo "https://yams.media/config" echo echo "========================================================" exit 0 -# ============================================================================================ diff --git a/install_new.sh b/install_new.sh deleted file mode 100644 index e6b0b08..0000000 --- a/install_new.sh +++ /dev/null @@ -1,268 +0,0 @@ -#!/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 }') - 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/" -} - -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 - -read -p "Where do you want to install the docker-compose file? [/opt/yams]: " install_location - -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 - -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"} - -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 - -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 - -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\"..." - -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//$puid/g" "$filename" - -# Set PGID -sed -i -e "s//$pgid/g" "$filename" - -# Set media_folder -sed -i -e "s;;$media_folder;g" "$filename" - -# Set media_service -sed -i -e "s;;$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;g" "$filename" - -# Set VPN -if [ "$setup_vpn" == "y" ]; then - sed -i -e "s;;$vpn_service;g" "$filename" - sed -i -e "s;;$vpn_user;g" "$filename" - sed -i -e "s;;$vpn_country;g" "$filename" - sed -i -e "s;;$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 - -sed -i -e "s;;$filename;g" yams -sed -i -e "s;;$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 - -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 -- cgit v1.2.3 From 067bc21560117ef0c845467c159850db6034393d Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 15:12:45 -0300 Subject: Set install as executable --- install.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 install.sh diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 -- cgit v1.2.3 From 48b9205da6686d0e2a8697f4deaa7cf04d808258 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 15:43:02 -0300 Subject: Testing the new docker-compose file --- .env.example | 11 ++++++ docker-compose.example.yaml | 88 ++++++++++++++++++++++----------------------- docs.org | 21 ++++++----- install.sh | 22 ++++++++---- 4 files changed, 80 insertions(+), 62 deletions(-) create mode 100644 .env.example mode change 100755 => 100644 install.sh diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..217fb1e --- /dev/null +++ b/.env.example @@ -0,0 +1,11 @@ +# Base configuration +PUID= +PGID= +MEDIA_FOLDER= +INSTALL_LOCATION= +MEDIA_SERVICE= + +# VPN configuration +VPN_SERVICE= +VPN_USER= +VPN_PASSWORD= diff --git a/docker-compose.example.yaml b/docker-compose.example.yaml index 5605e37..9658536 100644 --- a/docker-compose.example.yaml +++ b/docker-compose.example.yaml @@ -3,17 +3,17 @@ version: "3" services: # is used to serve your media to the client devices : - image: lscr.io/linuxserver/ - container_name: + image: lscr.io/linuxserver/${MEDIA_SERVICE} + container_name: ${MEDIA_SERVICE} #network_mode: host # plex environment: - - PUID= - - PGID= + - PUID=${PUID} + - PGID=${PGID} - VERSION=docker volumes: - - /movies:/data/movies - - /tvshows:/data/tvshows - - /config/:/config + - ${MEDIA_FOLDER}/movies:/data/movies + - ${MEDIA_FOLDER}/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= - - PGID= + - PUID=${PUID} + - PGID=${PGID} - WEB_UI_PORT=8080 volumes: - - /downloads:/downloads - - /config/qbittorrent:/config + - ${MEDIA_FOLDER}/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= - - PGID= + - PUID=${PUID} + - PGID=${PGID} volumes: - - /tvshows:/tv - - /downloads:/downloads - - /config/sonarr:/config + - ${MEDIA_FOLDER}/tvshows:/tv + - ${MEDIA_FOLDER}/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= - - PGID= + - PUID=${PUID} + - PGID=${PGID} volumes: - - /movies:/movies - - /downloads:/downloads - - /config/radarr:/config + - ${MEDIA_FOLDER}/movies:/movies + - ${MEDIA_FOLDER}/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= - - PGID= + - PUID=${PUID} + - PGID=${PGID} volumes: - - /music:/music - - /downloads:/downloads - - /config/lidarr:/config + - ${MEDIA_FOLDER}/music:/music + - ${MEDIA_FOLDER}/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= - - PGID= + - PUID=${PUID} + - PGID=${PGID} volumes: - - /books:/books - - /downloads:/downloads - - /config/readarr:/config + - ${MEDIA_FOLDER}/books:/books + - ${MEDIA_FOLDER}/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= - - PGID= + - PUID=${PUID} + - PGID=${PGID} volumes: - - /movies:/movies - - /tvshows:/tv - - /config/bazarr:/config + - ${MEDIA_FOLDER}/movies:/movies + - ${MEDIA_FOLDER}/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= - - PGID= + - PUID=${PUID} + - PGID=${PGID} volumes: - - /config/prowlarr:/config + - ${INSTALL_LOCATION}/config/prowlarr:/config ports: - 9696:9696 restart: unless-stopped @@ -142,12 +142,12 @@ services: - 8388:8388/udp # Shadowsocks #- 8080:8080/tcp # gluetun volumes: - - /config/gluetun:/config + - ${INSTALL_LOCATION}/config/gluetun:/config environment: - - VPN_SERVICE_PROVIDER= + - VPN_SERVICE_PROVIDER=${VPN_SERVICE} - VPN_TYPE=openvpn - - OPENVPN_USER= - - OPENVPN_PASSWORD= + - OPENVPN_USER=${VPN_USER} + - OPENVPN_PASSWORD=${VPN_PASSWORD} - OPENVPN_CIPHERS=AES-256-GCM restart: unless-stopped @@ -160,7 +160,7 @@ services: volumes: - /etc/localtime:/etc/localtime:ro - /var/run/docker.sock:/var/run/docker.sock:ro - - /config/portainer:/data + - ${INSTALL_LOCATION}/config/portainer:/data restart: unless-stopped # Watchtower is going to keep our instances updated diff --git a/docs.org b/docs.org index fcac196..70ffe19 100644 --- a/docs.org +++ b/docs.org @@ -180,6 +180,7 @@ 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" +env_file="$install_location/.env" read -p "What's the user that is going to own the media server files? [$USER]: " username @@ -316,6 +317,7 @@ echo "" echo "Copying $filename..." cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" +cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" #+end_src ** Set PUID, PGID, Media Folder, Media Service, Config folder and VPN @@ -325,36 +327,33 @@ cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($US #+begin_src bash # Set PUID -sed -i -e "s//$puid/g" "$filename" +sed -i -e "s//$puid/g" "$env_file" # Set PGID -sed -i -e "s//$pgid/g" "$filename" +sed -i -e "s//$pgid/g" "$env_file" # Set media_folder -sed -i -e "s;;$media_folder;g" "$filename" +sed -i -e "s;;$media_folder;g" "$env_file" # Set media_service +sed -i -e "s;;$media_service;g" "$env_file" sed -i -e "s;;$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;g" "$filename" +sed -i -e "s;;$install_location;g" "$env_file" # Set VPN if [ "$setup_vpn" == "y" ]; then - sed -i -e "s;;$vpn_service;g" "$filename" - sed -i -e "s;;$vpn_user;g" "$filename" - sed -i -e "s;;$vpn_country;g" "$filename" - sed -i -e "s;;$vpn_password;g" "$filename" + sed -i -e "s;;$vpn_service;g" "$env_file" + sed -i -e "s;;$vpn_user;g" "$env_file" + sed -i -e "s;;$vpn_password;g" "$env_file" 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 #+end_src diff --git a/install.sh b/install.sh old mode 100755 new mode 100644 index eeb9f7b..b943422 --- a/install.sh +++ b/install.sh @@ -77,6 +77,7 @@ 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" +env_file="$install_location/.env" read -p "What's the user that is going to own the media server files? [$USER]: " username @@ -168,6 +169,11 @@ if [ "$setup_vpn" == "y" ]; then 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\"..." @@ -176,30 +182,32 @@ echo "" echo "Copying $filename..." cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" +cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" # Set PUID -sed -i -e "s//$puid/g" "$filename" +sed -i -e "s//$puid/g" "$env_file" # Set PGID -sed -i -e "s//$pgid/g" "$filename" +sed -i -e "s//$pgid/g" "$env_file" # Set media_folder -sed -i -e "s;;$media_folder;g" "$filename" +sed -i -e "s;;$media_folder;g" "$env_file" # Set media_service +sed -i -e "s;;$media_service;g" "$env_file" sed -i -e "s;;$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;g" "$filename" +sed -i -e "s;;$install_location;g" "$env_file" # Set VPN if [ "$setup_vpn" == "y" ]; then - sed -i -e "s;;$vpn_service;g" "$filename" - sed -i -e "s;;$vpn_user;g" "$filename" - sed -i -e "s;;$vpn_password;g" "$filename" + sed -i -e "s;;$vpn_service;g" "$env_file" + sed -i -e "s;;$vpn_user;g" "$env_file" + sed -i -e "s;;$vpn_password;g" "$env_file" 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" -- cgit v1.2.3 From 6e94df162b9c98da80d1c60c8ccc88151837fb55 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 15:45:11 -0300 Subject: Deleted countries from VPN --- docs.org | 5 ----- install.sh | 5 ----- 2 files changed, 10 deletions(-) diff --git a/docs.org b/docs.org index 70ffe19..0cfe411 100644 --- a/docs.org +++ b/docs.org @@ -293,11 +293,6 @@ if [ "$setup_vpn" == "y" ]; then 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\"..." diff --git a/install.sh b/install.sh index b943422..223708a 100644 --- a/install.sh +++ b/install.sh @@ -169,11 +169,6 @@ if [ "$setup_vpn" == "y" ]; then 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\"..." -- cgit v1.2.3 From dbf07bbcb290270401ec0bc069355a278f8f10f4 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 16:18:51 -0300 Subject: Testing update functionality --- yams | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/yams b/yams index 7ca1622..1a5163f 100755 --- a/yams +++ b/yams @@ -3,6 +3,7 @@ set -euo pipefail dc="docker-compose -f " +install_location="" option=${1:-"--help"} @@ -17,6 +18,7 @@ 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() { @@ -81,3 +83,21 @@ 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;g" "$filename" + if [ "$MEDIA_SERVICE" == "plex" ]; then + sed -i -e "s;#network_mode: host # plex;network_mode: host # plex;g" "$filename" + fi +fi -- cgit v1.2.3 From 72c31fd328c73a679cac7d6fe3cc5eb7b02522ab Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 16:31:55 -0300 Subject: Fixed formatting in yams script --- yams | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/yams b/yams index 1a5163f..d198eba 100755 --- a/yams +++ b/yams @@ -18,41 +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 + 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" @@ -63,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 + read -pr "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 @@ -84,7 +84,7 @@ if [ $option == "destroy" ]; then fi fi -if [ $option == "update" ]; then +if [ "$option" == "update" ]; then echo "Updating YAMS..." $dc stop rm -rf /tmp/yams && mkdir /tmp/yams -- cgit v1.2.3 From 57826c7c11fb79e65928c97722e88b1a85e8e460 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 16:35:51 -0300 Subject: Added vpn setup for yams update --- .env.example | 1 + docs.org | 1 + install.sh | 1 + yams | 7 +++++++ 4 files changed, 10 insertions(+) diff --git a/.env.example b/.env.example index 217fb1e..705d7c1 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,7 @@ INSTALL_LOCATION= MEDIA_SERVICE= # VPN configuration +VPN_ENABLED= VPN_SERVICE= VPN_USER= VPN_PASSWORD= diff --git a/docs.org b/docs.org index 0cfe411..0f95413 100644 --- a/docs.org +++ b/docs.org @@ -345,6 +345,7 @@ if [ "$setup_vpn" == "y" ]; then sed -i -e "s;;$vpn_service;g" "$env_file" sed -i -e "s;;$vpn_user;g" "$env_file" sed -i -e "s;;$vpn_password;g" "$env_file" + sed -i -e "s;;$setup_vpn;g" "$env_file" 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" diff --git a/install.sh b/install.sh index 223708a..5562881 100644 --- a/install.sh +++ b/install.sh @@ -203,6 +203,7 @@ if [ "$setup_vpn" == "y" ]; then sed -i -e "s;;$vpn_service;g" "$env_file" sed -i -e "s;;$vpn_user;g" "$env_file" sed -i -e "s;;$vpn_password;g" "$env_file" + sed -i -e "s;;$setup_vpn;g" "$env_file" 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" diff --git a/yams b/yams index d198eba..20ef3c2 100755 --- a/yams +++ b/yams @@ -100,4 +100,11 @@ if [ "$option" == "update" ]; then 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" + 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" + fi fi -- cgit v1.2.3 From 6d11cd366d71878ec6c88e6df5046ea038bdfabc Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 16:37:19 -0300 Subject: Fixed issue with -r in read --- yams | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yams b/yams index 20ef3c2..8fc0417 100755 --- a/yams +++ b/yams @@ -73,7 +73,7 @@ fi if [ "$option" == "destroy" ]; then echo echo - read -pr "Are you sure you want to destroy all your yams services? THIS IS NOT RECOVERABLE! ⚠️ ️🚨 [y/N]: " destroy_now + 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 -- cgit v1.2.3 From 2331e9a47667c96ddd3a00e66e5941ae2c272eb2 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 16:40:54 -0300 Subject: Restarting YAMS after update --- yams | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yams b/yams index 8fc0417..15bc4ad 100755 --- a/yams +++ b/yams @@ -107,4 +107,7 @@ if [ "$option" == "update" ]; then 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" fi + + $dc up -d + echo "YAMS was updated and it is starting. Wait 1 min until all the services are up and running..." fi -- cgit v1.2.3 From 7252aa95dcc009b26dcb8e498d1d9b807fac486b Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 16:44:52 -0300 Subject: Moving `sed`s to only one command --- docs.org | 31 ++++++++++++------------------- install.sh | 31 ++++++++++++------------------- yams | 8 ++++---- 3 files changed, 28 insertions(+), 42 deletions(-) diff --git a/docs.org b/docs.org index 0f95413..dbce65f 100644 --- a/docs.org +++ b/docs.org @@ -321,35 +321,28 @@ cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to ha :END: #+begin_src bash -# Set PUID sed -i -e "s//$puid/g" "$env_file" + -e "s//$pgid/g" "$env_file" \ + -e "s;;$media_folder;g" "$env_file" \ + -e "s;;$media_service;g" "$env_file" \ + -e "s;;$media_service;g" "$filename" -# Set PGID -sed -i -e "s//$pgid/g" "$env_file" - -# Set media_folder -sed -i -e "s;;$media_folder;g" "$env_file" - -# Set media_service -sed -i -e "s;;$media_service;g" "$env_file" -sed -i -e "s;;$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;g" "$env_file" # Set VPN if [ "$setup_vpn" == "y" ]; then - sed -i -e "s;;$vpn_service;g" "$env_file" - sed -i -e "s;;$vpn_user;g" "$env_file" - sed -i -e "s;;$vpn_password;g" "$env_file" - sed -i -e "s;;$setup_vpn;g" "$env_file" - 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" + sed -i -e "s;;$vpn_service;g" "$env_file" \ + -e "s;;$vpn_user;g" "$env_file" \ + -e "s;;$vpn_password;g" "$env_file" \ + -e "s;;$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 diff --git a/install.sh b/install.sh index 5562881..28a4e68 100644 --- a/install.sh +++ b/install.sh @@ -179,35 +179,28 @@ echo "Copying $filename..." cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" -# Set PUID sed -i -e "s//$puid/g" "$env_file" + -e "s//$pgid/g" "$env_file" \ + -e "s;;$media_folder;g" "$env_file" \ + -e "s;;$media_service;g" "$env_file" \ + -e "s;;$media_service;g" "$filename" -# Set PGID -sed -i -e "s//$pgid/g" "$env_file" - -# Set media_folder -sed -i -e "s;;$media_folder;g" "$env_file" - -# Set media_service -sed -i -e "s;;$media_service;g" "$env_file" -sed -i -e "s;;$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;g" "$env_file" # Set VPN if [ "$setup_vpn" == "y" ]; then - sed -i -e "s;;$vpn_service;g" "$env_file" - sed -i -e "s;;$vpn_user;g" "$env_file" - sed -i -e "s;;$vpn_password;g" "$env_file" - sed -i -e "s;;$setup_vpn;g" "$env_file" - 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" + sed -i -e "s;;$vpn_service;g" "$env_file" \ + -e "s;;$vpn_user;g" "$env_file" \ + -e "s;;$vpn_password;g" "$env_file" \ + -e "s;;$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;g" yams diff --git a/yams b/yams index 15bc4ad..0f103d4 100755 --- a/yams +++ b/yams @@ -102,10 +102,10 @@ if [ "$option" == "update" ]; then fi if [ "$VPN_ENABLED" == "y" ]; then - 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" + 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 -- cgit v1.2.3 From fe2eae985ee9b339387fe7dc313b3c524202f235 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 16:48:50 -0300 Subject: Fixed typo --- docs.org | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs.org b/docs.org index dbce65f..921522f 100644 --- a/docs.org +++ b/docs.org @@ -321,7 +321,7 @@ cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to ha :END: #+begin_src bash -sed -i -e "s//$puid/g" "$env_file" +sed -i -e "s//$puid/g" "$env_file" \ -e "s//$pgid/g" "$env_file" \ -e "s;;$media_folder;g" "$env_file" \ -e "s;;$media_service;g" "$env_file" \ diff --git a/install.sh b/install.sh index 28a4e68..07c3d9e 100644 --- a/install.sh +++ b/install.sh @@ -179,7 +179,7 @@ echo "Copying $filename..." cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" -sed -i -e "s//$puid/g" "$env_file" +sed -i -e "s//$puid/g" "$env_file" \ -e "s//$pgid/g" "$env_file" \ -e "s;;$media_folder;g" "$env_file" \ -e "s;;$media_service;g" "$env_file" \ -- cgit v1.2.3 From 48967cc0329957b129efb120c3e4a940352c7e69 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 16:58:45 -0300 Subject: Added custom docker-compose file --- docker-compose.custom.yaml | 4 ++++ docs.org | 7 +++++-- install.sh | 7 +++++-- yams | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 docker-compose.custom.yaml diff --git a/docker-compose.custom.yaml b/docker-compose.custom.yaml new file mode 100644 index 0000000..a108a1c --- /dev/null +++ b/docker-compose.custom.yaml @@ -0,0 +1,4 @@ +version: "3" + +services: + # Add your custom services here! diff --git a/docs.org b/docs.org index 921522f..bedb28b 100644 --- a/docs.org +++ b/docs.org @@ -180,6 +180,7 @@ 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" +custom_file_filename="$install_location/docker-compose.custom.yaml" env_file="$install_location/.env" read -p "What's the user that is going to own the media server files? [$USER]: " username @@ -313,6 +314,7 @@ echo "Copying $filename..." cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" +cp docker-compose.custom.yaml "$custom_file_filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" #+end_src ** Set PUID, PGID, Media Folder, Media Service, Config folder and VPN @@ -352,8 +354,9 @@ fi :END: #+begin_src bash -sed -i -e "s;;$filename;g" yams -sed -i -e "s;;$install_location;g" yams +sed -i -e "s;;$filename;g" yams \ + -e "s;;$custom_file_filename;g" yams \ + -e "s;;$install_location;g" yams #+end_src ** Success message! diff --git a/install.sh b/install.sh index 07c3d9e..6619a96 100644 --- a/install.sh +++ b/install.sh @@ -77,6 +77,7 @@ 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" +custom_file_filename="$install_location/docker-compose.custom.yaml" env_file="$install_location/.env" read -p "What's the user that is going to own the media server files? [$USER]: " username @@ -178,6 +179,7 @@ echo "Copying $filename..." cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" +cp docker-compose.custom.yaml "$custom_file_filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" sed -i -e "s//$puid/g" "$env_file" \ -e "s//$pgid/g" "$env_file" \ @@ -203,8 +205,9 @@ if [ "$setup_vpn" == "y" ]; then -e "s;#- 8080:8080/tcp # gluetun;- 8080:8080/tcp # gluetun;g" "$filename" fi -sed -i -e "s;;$filename;g" yams -sed -i -e "s;;$install_location;g" yams +sed -i -e "s;;$filename;g" yams \ + -e "s;;$custom_file_filename;g" yams \ + -e "s;;$install_location;g" yams send_success_message "Everything installed correctly! 🎉" diff --git a/yams b/yams index 0f103d4..db49e83 100755 --- a/yams +++ b/yams @@ -2,7 +2,7 @@ set -euo pipefail -dc="docker-compose -f " +dc="docker-compose -f -f " install_location="" option=${1:-"--help"} -- cgit v1.2.3 From 33fd76fb8e23bd57efce49ddce9eba8013fa9e6d Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 17:03:29 -0300 Subject: Commented out the services directive --- docker-compose.custom.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.custom.yaml b/docker-compose.custom.yaml index a108a1c..236a651 100644 --- a/docker-compose.custom.yaml +++ b/docker-compose.custom.yaml @@ -1,4 +1,4 @@ version: "3" -services: +# services: # Add your custom services here! -- cgit v1.2.3 From 9ba61badade523b40dd4de721240325e1d248ac6 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 17:12:24 -0300 Subject: Refactored the final steps to make it more readable --- docs.org | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------- install.sh | 45 +++++++++++++++++++++++++++++++++----- 2 files changed, 105 insertions(+), 14 deletions(-) diff --git a/docs.org b/docs.org index bedb28b..7d1758e 100644 --- a/docs.org +++ b/docs.org @@ -23,8 +23,10 @@ - [[#set-puid-pgid-media-folder-media-service-config-folder-and-vpn][Set PUID, PGID, Media Folder, Media Service, Config folder and VPN]] - [[#set-the-configuration-for-the-yams-binary][Set the configuration for the YAMS binary]] - [[#success-message][Success message!]] -- [[#clean-up][Clean up]] +- [[#final-steps][Final steps]] - [[#install-the-yams-cli][Install the YAMS CLI]] + - [[#create-and-set-the-correct-permissions-to-the-media-folder][Create and set the correct permissions to the media folder]] + - [[#create-the-config-directory][Create the config directory]] - [[#display-closing-message][Display closing message]] * Welcome message @@ -374,7 +376,7 @@ echo "This is going to take a while..." docker-compose -f "$filename" up -d #+end_src -* Clean up +* Final steps :PROPERTIES: :ID: 65ce5828-b69a-4a0e-83f6-b029e19caea1 :END: @@ -383,13 +385,69 @@ docker-compose -f "$filename" up -d :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 + echo "YAMS CLI installed successfully." +else + send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions." +fi +#+end_src + +** Create and set the correct permissions to the media folder +:PROPERTIES: +:ID: 4cfb9397-776d-46db-84cc-54b78395cba8 +:END: + +Now, we validate the media folder exists. If it doesn't we'll try and create it. If it can't be created, +it will raise an error. + +#+begin_src bash +if [[ -d "$media_folder" ]]; then + echo "Media folder \"$media_folder\" exists." +else + if sudo mkdir -p "$media_folder"; then + echo "Media folder \"$media_folder\" created." + else + send_error_message "Failed to create or access the media folder. Check permissions." + fi +fi + +if sudo chown -R "$puid":"$pgid" "$media_folder"; then + echo "Media folder ownership and permissions set successfully." +else + send_error_message "Failed to set ownership and permissions for the media folder. 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 -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" +if [[ -d "$install_location/config" ]]; then + echo "Configuration folder \"$install_location/config\" exists." +else + if sudo mkdir -p "$install_location/config"; then + echo "Configuration folder \"$install_location/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_location/config"; then + echo "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 diff --git a/install.sh b/install.sh index 6619a96..54f51df 100644 --- a/install.sh +++ b/install.sh @@ -216,12 +216,45 @@ echo "This is going to take a while..." docker-compose -f "$filename" up -d -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" +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 + echo "YAMS CLI installed successfully." +else + send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions." +fi + +if [[ -d "$media_folder" ]]; then + echo "Media folder \"$media_folder\" exists." +else + if sudo mkdir -p "$media_folder"; then + echo "Media folder \"$media_folder\" created." + else + send_error_message "Failed to create or access the media folder. Check permissions." + fi +fi + +if sudo chown -R "$puid":"$pgid" "$media_folder"; then + echo "Media folder ownership and permissions set successfully." +else + send_error_message "Failed to set ownership and permissions for the media folder. Check permissions." +fi + +if [[ -d "$install_location/config" ]]; then + echo "Configuration folder \"$install_location/config\" exists." +else + if sudo mkdir -p "$install_location/config"; then + echo "Configuration folder \"$install_location/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_location/config"; then + echo "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" -- cgit v1.2.3 From 3ecbb4477b6857076013b8c930cef798307d6a46 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 17:17:09 -0300 Subject: Using formatting message functions to better display the messages --- docs.org | 24 ++++++++++++------------ install.sh | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs.org b/docs.org index 7d1758e..c69eee8 100644 --- a/docs.org +++ b/docs.org @@ -392,9 +392,9 @@ directory. 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 - echo "YAMS CLI installed successfully." + send_success_message "YAMS CLI installed successfully ✅" else - send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions." + send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions ❌" fi #+end_src @@ -408,19 +408,19 @@ it will raise an error. #+begin_src bash if [[ -d "$media_folder" ]]; then - echo "Media folder \"$media_folder\" exists." + send_success_message "Media folder \"$media_folder\" exists ✅" else if sudo mkdir -p "$media_folder"; then - echo "Media folder \"$media_folder\" created." + send_success_message "Media folder \"$media_folder\" created ✅" else - send_error_message "Failed to create or access the media folder. Check permissions." + send_error_message "Failed to create or access the media folder. Check permissions ❌" fi fi if sudo chown -R "$puid":"$pgid" "$media_folder"; then - echo "Media folder ownership and permissions set successfully." + send_success_message "Media folder ownership and permissions set successfully ✅" else - send_error_message "Failed to set ownership and permissions for the media folder. Check permissions." + send_error_message "Failed to set ownership and permissions for the media folder. Check permissions ❌" fi #+end_src @@ -434,19 +434,19 @@ it can't be created, we'll raise an error. #+begin_src bash if [[ -d "$install_location/config" ]]; then - echo "Configuration folder \"$install_location/config\" exists." + send_success_message "Configuration folder \"$install_location/config\" exists ✅" else if sudo mkdir -p "$install_location/config"; then - echo "Configuration folder \"$install_location/config\" created." + send_success_message "Configuration folder \"$install_location/config\" created ✅" else - send_error_message "Failed to create or access the configuration folder. Check permissions." + send_error_message "Failed to create or access the configuration folder. Check permissions ❌" fi fi if sudo chown -R "$puid":"$pgid" "$install_location/config"; then - echo "Configuration folder ownership and permissions set successfully." + 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." + send_error_message "Failed to set ownership and permissions for the configuration folder. Check permissions ❌" fi #+end_src diff --git a/install.sh b/install.sh index 54f51df..5eff501 100644 --- a/install.sh +++ b/install.sh @@ -219,41 +219,41 @@ 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 - echo "YAMS CLI installed successfully." + send_success_message "YAMS CLI installed successfully ✅" else - send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions." + send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions ❌" fi if [[ -d "$media_folder" ]]; then - echo "Media folder \"$media_folder\" exists." + send_success_message "Media folder \"$media_folder\" exists ✅" else if sudo mkdir -p "$media_folder"; then - echo "Media folder \"$media_folder\" created." + send_success_message "Media folder \"$media_folder\" created ✅" else - send_error_message "Failed to create or access the media folder. Check permissions." + send_error_message "Failed to create or access the media folder. Check permissions ❌" fi fi if sudo chown -R "$puid":"$pgid" "$media_folder"; then - echo "Media folder ownership and permissions set successfully." + send_success_message "Media folder ownership and permissions set successfully ✅" else - send_error_message "Failed to set ownership and permissions for the media folder. Check permissions." + send_error_message "Failed to set ownership and permissions for the media folder. Check permissions ❌" fi if [[ -d "$install_location/config" ]]; then - echo "Configuration folder \"$install_location/config\" exists." + send_success_message "Configuration folder \"$install_location/config\" exists ✅" else if sudo mkdir -p "$install_location/config"; then - echo "Configuration folder \"$install_location/config\" created." + send_success_message "Configuration folder \"$install_location/config\" created ✅" else - send_error_message "Failed to create or access the configuration folder. Check permissions." + send_error_message "Failed to create or access the configuration folder. Check permissions ❌" fi fi if sudo chown -R "$puid":"$pgid" "$install_location/config"; then - echo "Configuration folder ownership and permissions set successfully." + 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." + send_error_message "Failed to set ownership and permissions for the configuration folder. Check permissions ❌" fi printf "\033c" -- cgit v1.2.3 From 63a453951ef703a0408876889fae469ab41472e2 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 17:25:19 -0300 Subject: Refactored the "Installing YAMS" portion --- docs.org | 65 ++++++++++++++++++++++++++++++++++++-------------------------- install.sh | 58 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 71 insertions(+), 52 deletions(-) diff --git a/docs.org b/docs.org index c69eee8..73d6f78 100644 --- a/docs.org +++ b/docs.org @@ -20,7 +20,7 @@ - [[#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][Set PUID, PGID, Media Folder, Media Service, Config folder and VPN]] + - [[#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]] @@ -311,42 +311,53 @@ echo "Configuring the docker-compose file for the user \"$username\" on \"$insta :END: #+begin_src bash -echo "" -echo "Copying $filename..." - -cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" -cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" -cp docker-compose.custom.yaml "$custom_file_filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" +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_error_message "Failed to copy $source_file to $destination_file. Ensure your user ($USER) has the necessary permissions." + fi +done #+end_src -** Set PUID, PGID, Media Folder, Media Service, Config folder and VPN +** 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//$puid/g" "$env_file" \ - -e "s//$pgid/g" "$env_file" \ - -e "s;;$media_folder;g" "$env_file" \ - -e "s;;$media_service;g" "$env_file" \ - -e "s;;$media_service;g" "$filename" +sed -i -e "s||$puid|g" "$env_file" \ + -e "s||$pgid|g" "$env_file" \ + -e "s||$media_folder|g" "$env_file" \ + -e "s||$media_service|g" "$env_file" \ + -e "s||$media_service|g" "$filename" if [ "$media_service" == "plex" ]; then - sed -i -e "s;#network_mode: host # plex;network_mode: host # plex;g" "$filename" + sed -i -e "s|#network_mode: host # plex|network_mode: host # plex|g" "$filename" fi -sed -i -e "s;;$install_location;g" "$env_file" +sed -i -e "s||$install_location|g" "$env_file" -# Set VPN if [ "$setup_vpn" == "y" ]; then - sed -i -e "s;;$vpn_service;g" "$env_file" \ - -e "s;;$vpn_user;g" "$env_file" \ - -e "s;;$vpn_password;g" "$env_file" \ - -e "s;;$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" + sed -i -e "s||$vpn_service|g" "$env_file" \ + -e "s||$vpn_user|g" "$env_file" \ + -e "s||$vpn_password|g" "$env_file" \ + -e "s||$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 @@ -356,9 +367,9 @@ fi :END: #+begin_src bash -sed -i -e "s;;$filename;g" yams \ - -e "s;;$custom_file_filename;g" yams \ - -e "s;;$install_location;g" yams +sed -i -e "s||$filename|g" yams \ + -e "s||$custom_file_filename|g" yams \ + -e "s||$install_location|g" yams #+end_src ** Success message! diff --git a/install.sh b/install.sh index 5eff501..5ec03b4 100644 --- a/install.sh +++ b/install.sh @@ -174,40 +174,48 @@ fi echo "Configuring the docker-compose file for the user \"$username\" on \"$install_location\"..." -echo "" -echo "Copying $filename..." - -cp docker-compose.example.yaml "$filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" -cp .env.example "$env_file" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" -cp docker-compose.custom.yaml "$custom_file_filename" || send_error_message "Your user ($USER) needs to have permissions on the installation folder!" +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_error_message "Failed to copy $source_file to $destination_file. Ensure your user ($USER) has the necessary permissions." + fi +done -sed -i -e "s//$puid/g" "$env_file" \ - -e "s//$pgid/g" "$env_file" \ - -e "s;;$media_folder;g" "$env_file" \ - -e "s;;$media_service;g" "$env_file" \ - -e "s;;$media_service;g" "$filename" +sed -i -e "s||$puid|g" "$env_file" \ + -e "s||$pgid|g" "$env_file" \ + -e "s||$media_folder|g" "$env_file" \ + -e "s||$media_service|g" "$env_file" \ + -e "s||$media_service|g" "$filename" if [ "$media_service" == "plex" ]; then - sed -i -e "s;#network_mode: host # plex;network_mode: host # plex;g" "$filename" + sed -i -e "s|#network_mode: host # plex|network_mode: host # plex|g" "$filename" fi -sed -i -e "s;;$install_location;g" "$env_file" +sed -i -e "s||$install_location|g" "$env_file" -# Set VPN if [ "$setup_vpn" == "y" ]; then - sed -i -e "s;;$vpn_service;g" "$env_file" \ - -e "s;;$vpn_user;g" "$env_file" \ - -e "s;;$vpn_password;g" "$env_file" \ - -e "s;;$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" + sed -i -e "s||$vpn_service|g" "$env_file" \ + -e "s||$vpn_user|g" "$env_file" \ + -e "s||$vpn_password|g" "$env_file" \ + -e "s||$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;g" yams \ - -e "s;;$custom_file_filename;g" yams \ - -e "s;;$install_location;g" yams +sed -i -e "s||$filename|g" yams \ + -e "s||$custom_file_filename|g" yams \ + -e "s||$install_location|g" yams send_success_message "Everything installed correctly! 🎉" -- cgit v1.2.3 From 612eb32cd880364f8ae75ff7b7f9ed1634ee5763 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:12:03 -0300 Subject: Refactored the information gathering section --- docs.org | 90 ++++++++++++++++++++++++++++++++------------------------------ install.sh | 65 ++++++++++++++++++++------------------------- 2 files changed, 75 insertions(+), 80 deletions(-) diff --git a/docs.org b/docs.org index 73d6f78..1ae770d 100644 --- a/docs.org +++ b/docs.org @@ -15,7 +15,8 @@ - [[#verify-all-the-dependencies][Verify all the dependencies]] - [[#gather-all-the-required-information][Gather all the required information]] - [[#checking-install-location][Checking install location]] - - [[#verify-media-folder][Verify media folder]] + - [[#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]] @@ -25,7 +26,7 @@ - [[#success-message][Success message!]] - [[#final-steps][Final steps]] - [[#install-the-yams-cli][Install the YAMS CLI]] - - [[#create-and-set-the-correct-permissions-to-the-media-folder][Create and set the correct permissions to the media folder]] + - [[#set-the-correct-permissions-to-the-media-folder][Set the correct permissions to the media folder]] - [[#create-the-config-directory][Create the config directory]] - [[#display-closing-message][Display closing message]] @@ -176,17 +177,29 @@ fi :END: #+begin_src bash -read -p "Where do you want to install the docker-compose file? [/opt/yams]: " install_location +default_install_location="/opt/yams" + +read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_location +install_location=${install_location:-$default_install_location} + +if [ ! -d "$install_location" ]; then + if ! mkdir -p "$install_location"; then + send_error_message "There was an error creating the installation directory at \"$install_location\". Make sure you have the necessary permissions." + fi +fi -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" custom_file_filename="$install_location/docker-compose.custom.yaml" env_file="$install_location/.env" +#+end_src -read -p "What's the user that is going to own the media server files? [$USER]: " username +** 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 @@ -195,26 +208,26 @@ if id -u "$username" &>/dev/null; then 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"} #+end_src -** Verify media folder +** Media directory :PROPERTIES: :ID: 9726dead-8833-4f23-98b8-2790d72605de :END: #+begin_src bash -realpath "$media_folder" &>/dev/null || send_error_message "There was an error with your media folder! The directory \"$media_folder\" does not exist!" +read -p "Please, input your media folder [/srv/media]: " media_folder +media_folder=${media_folder:-"/srv/media"} -media_folder=$(realpath "$media_folder") +if [ ! -d "$media_folder" ]; then + send_error_message "The directory \"$media_folder\" does not exist!" +fi 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" + send_error_message "Media folder is not correct. Please fix it and run the script again ❌" fi #+end_src @@ -224,18 +237,16 @@ fi :END: #+begin_src bash -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 -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" | sed -e 's/\(.*\)/\L\1/') +media_service=$(echo "$media_service" | awk '{print tolower($0)}') media_service_port=8096 if [ "$media_service" == "plex" ]; then @@ -243,7 +254,7 @@ if [ "$media_service" == "plex" ]; then fi if echo "emby plex jellyfin" | grep -qw "$media_service"; then - echo "YAMS is going to install \"$media_service\" on port \"$media_service_port\"" + 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 @@ -255,21 +266,19 @@ fi :END: #+begin_src bash -echo -echo -echo -echo "Time to set up the VPN." +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 - echo "You should read $vpn_service's documentation in case it has different configurations for username and password." + + 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" - echo + read -p "What's your VPN username? (without spaces): " vpn_user unset vpn_password @@ -322,12 +331,16 @@ for file_mapping in "${copy_files[@]}"; do destination_file="${file_mapping##*:}" echo -e "\nCopying $source_file to $destination_file..." - if ! cp "$source_file" "$destination_file"; then - send_error_message "Failed to copy $source_file to $destination_file. Ensure your user ($USER) has the necessary permissions." + 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 @@ -409,25 +422,14 @@ else fi #+end_src -** Create and set the correct permissions to the media folder +** Set the correct permissions to the media folder :PROPERTIES: :ID: 4cfb9397-776d-46db-84cc-54b78395cba8 :END: -Now, we validate the media folder exists. If it doesn't we'll try and create it. If it can't be created, -it will raise an error. +This adds the correct permissions to the media folder, in case they are not correct. #+begin_src bash -if [[ -d "$media_folder" ]]; then - send_success_message "Media folder \"$media_folder\" exists ✅" -else - if sudo mkdir -p "$media_folder"; then - send_success_message "Media folder \"$media_folder\" created ✅" - else - send_error_message "Failed to create or access the media folder. Check permissions ❌" - fi -fi - if sudo chown -R "$puid":"$pgid" "$media_folder"; then send_success_message "Media folder ownership and permissions set successfully ✅" else diff --git a/install.sh b/install.sh index 5ec03b4..1e10454 100644 --- a/install.sh +++ b/install.sh @@ -71,17 +71,22 @@ if [[ "$EUID" = 0 ]]; then send_error_message "YAMS has to run without sudo! Please, run it again with regular permissions" fi -read -p "Where do you want to install the docker-compose file? [/opt/yams]: " install_location +default_install_location="/opt/yams" + +read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_location +install_location=${install_location:-$default_install_location} + +if [ ! -d "$install_location" ]; then + if ! mkdir -p "$install_location"; then + send_error_message "There was an error creating the installation directory at \"$install_location\". Make sure you have the necessary permissions." + fi +fi -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" custom_file_filename="$install_location/docker-compose.custom.yaml" env_file="$install_location/.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 @@ -94,29 +99,27 @@ fi read -p "Please, input your media folder [/srv/media]: " media_folder media_folder=${media_folder:-"/srv/media"} -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") +if [ ! -d "$media_folder" ]; then + send_error_message "The directory \"$media_folder\" does not exist!" +fi 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" + send_error_message "Media folder is not correct. Please fix it and run the script again ❌" fi -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 -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" | sed -e 's/\(.*\)/\L\1/') +media_service=$(echo "$media_service" | awk '{print tolower($0)}') media_service_port=8096 if [ "$media_service" == "plex" ]; then @@ -124,26 +127,24 @@ if [ "$media_service" == "plex" ]; then fi if echo "emby plex jellyfin" | grep -qw "$media_service"; then - echo "YAMS is going to install \"$media_service\" on port \"$media_service_port\"" + 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 -echo -echo -echo "Time to set up the VPN." +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 - echo "You should read $vpn_service's documentation in case it has different configurations for username and password." + + 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" - echo + read -p "What's your VPN username? (without spaces): " vpn_user unset vpn_password @@ -185,8 +186,10 @@ for file_mapping in "${copy_files[@]}"; do destination_file="${file_mapping##*:}" echo -e "\nCopying $source_file to $destination_file..." - if ! cp "$source_file" "$destination_file"; then - send_error_message "Failed to copy $source_file to $destination_file. Ensure your user ($USER) has the necessary permissions." + 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 @@ -232,16 +235,6 @@ else send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions ❌" fi -if [[ -d "$media_folder" ]]; then - send_success_message "Media folder \"$media_folder\" exists ✅" -else - if sudo mkdir -p "$media_folder"; then - send_success_message "Media folder \"$media_folder\" created ✅" - else - send_error_message "Failed to create or access the media folder. Check permissions ❌" - fi -fi - if sudo chown -R "$puid":"$pgid" "$media_folder"; then send_success_message "Media folder ownership and permissions set successfully ✅" else -- cgit v1.2.3 From 0be3a06df00adccc2c78c31d23108604d7aa1468 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:16:34 -0300 Subject: Made some small fixes in semantics --- docs.org | 6 ++++-- install.sh | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs.org b/docs.org index 1ae770d..d3f6550 100644 --- a/docs.org +++ b/docs.org @@ -184,7 +184,7 @@ install_location=${install_location:-$default_install_location} if [ ! -d "$install_location" ]; then if ! mkdir -p "$install_location"; then - send_error_message "There was an error creating the installation directory at \"$install_location\". Make sure you have the necessary permissions." + send_error_message "There was an error creating the installation directory at \"$install_location\". Make sure you have the necessary permissions ❌" fi fi @@ -220,7 +220,9 @@ read -p "Please, input your media folder [/srv/media]: " media_folder media_folder=${media_folder:-"/srv/media"} if [ ! -d "$media_folder" ]; then - send_error_message "The directory \"$media_folder\" does not exist!" + if ! mkdir -p "$media_folder"; then + send_error_message "There was an error creating the installation directory at \"$media_folder\". Make sure you have the necessary permissions ❌" + fi fi read -p "Are you sure your media folder is \"$media_folder\"? [y/N]: " media_folder_correct diff --git a/install.sh b/install.sh index 1e10454..7bc5e2d 100644 --- a/install.sh +++ b/install.sh @@ -78,7 +78,7 @@ install_location=${install_location:-$default_install_location} if [ ! -d "$install_location" ]; then if ! mkdir -p "$install_location"; then - send_error_message "There was an error creating the installation directory at \"$install_location\". Make sure you have the necessary permissions." + send_error_message "There was an error creating the installation directory at \"$install_location\". Make sure you have the necessary permissions ❌" fi fi @@ -100,7 +100,9 @@ read -p "Please, input your media folder [/srv/media]: " media_folder media_folder=${media_folder:-"/srv/media"} if [ ! -d "$media_folder" ]; then - send_error_message "The directory \"$media_folder\" does not exist!" + if ! mkdir -p "$media_folder"; then + send_error_message "There was an error creating the installation directory at \"$media_folder\". Make sure you have the necessary permissions ❌" + fi fi read -p "Are you sure your media folder is \"$media_folder\"? [y/N]: " media_folder_correct -- cgit v1.2.3 From 078fa2a18bc98029a8877c97d2b3dd6cb09b7f8f Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:21:56 -0300 Subject: Renamed "folder" to "directory" --- .env.example | 2 +- docker-compose.example.yaml | 26 +++++++++++++------------- docs.org | 27 +++++++++++++++------------ install.sh | 27 +++++++++++++++------------ 4 files changed, 44 insertions(+), 38 deletions(-) diff --git a/.env.example b/.env.example index 705d7c1..b137255 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ # Base configuration PUID= PGID= -MEDIA_FOLDER= +MEDIA_DIRECTORY= INSTALL_LOCATION= MEDIA_SERVICE= diff --git a/docker-compose.example.yaml b/docker-compose.example.yaml index 9658536..be3ec04 100644 --- a/docker-compose.example.yaml +++ b/docker-compose.example.yaml @@ -11,8 +11,8 @@ services: - PGID=${PGID} - VERSION=docker volumes: - - ${MEDIA_FOLDER}/movies:/data/movies - - ${MEDIA_FOLDER}/tvshows:/data/tvshows + - ${MEDIA_DIRECTORY}/movies:/data/movies + - ${MEDIA_DIRECTORY}/tvshows:/data/tvshows - ${INSTALL_LOCATION}/config/${MEDIA_SERVICE}:/config ports: - 8096:8096 @@ -27,7 +27,7 @@ services: - PGID=${PGID} - WEB_UI_PORT=8080 volumes: - - ${MEDIA_FOLDER}/downloads:/downloads + - ${MEDIA_DIRECTORY}/downloads:/downloads - ${INSTALL_LOCATION}/config/qbittorrent:/config restart: unless-stopped ports: # qbittorrent @@ -43,8 +43,8 @@ services: - PUID=${PUID} - PGID=${PGID} volumes: - - ${MEDIA_FOLDER}/tvshows:/tv - - ${MEDIA_FOLDER}/downloads:/downloads + - ${MEDIA_DIRECTORY}/tvshows:/tv + - ${MEDIA_DIRECTORY}/downloads:/downloads - ${INSTALL_LOCATION}/config/sonarr:/config ports: - 8989:8989 @@ -59,8 +59,8 @@ services: - PUID=${PUID} - PGID=${PGID} volumes: - - ${MEDIA_FOLDER}/movies:/movies - - ${MEDIA_FOLDER}/downloads:/downloads + - ${MEDIA_DIRECTORY}/movies:/movies + - ${MEDIA_DIRECTORY}/downloads:/downloads - ${INSTALL_LOCATION}/config/radarr:/config ports: - 7878:7878 @@ -75,8 +75,8 @@ services: - PUID=${PUID} - PGID=${PGID} volumes: - - ${MEDIA_FOLDER}/music:/music - - ${MEDIA_FOLDER}/downloads:/downloads + - ${MEDIA_DIRECTORY}/music:/music + - ${MEDIA_DIRECTORY}/downloads:/downloads - ${INSTALL_LOCATION}/config/lidarr:/config ports: - 8686:8686 @@ -91,8 +91,8 @@ services: - PUID=${PUID} - PGID=${PGID} volumes: - - ${MEDIA_FOLDER}/books:/books - - ${MEDIA_FOLDER}/downloads:/downloads + - ${MEDIA_DIRECTORY}/books:/books + - ${MEDIA_DIRECTORY}/downloads:/downloads - ${INSTALL_LOCATION}/config/readarr:/config ports: - 8787:8787 @@ -107,8 +107,8 @@ services: - PUID=${PUID} - PGID=${PGID} volumes: - - ${MEDIA_FOLDER}/movies:/movies - - ${MEDIA_FOLDER}/tvshows:/tv + - ${MEDIA_DIRECTORY}/movies:/movies + - ${MEDIA_DIRECTORY}/tvshows:/tv - ${INSTALL_LOCATION}/config/bazarr:/config ports: - 6767:6767 diff --git a/docs.org b/docs.org index d3f6550..8efb5bd 100644 --- a/docs.org +++ b/docs.org @@ -216,20 +216,23 @@ fi :END: #+begin_src bash -read -p "Please, input your media folder [/srv/media]: " media_folder -media_folder=${media_folder:-"/srv/media"} +read -p "Please, input your media directory [/srv/media]: " media_folder +media_directory=${media_directory:-"/srv/media"} -if [ ! -d "$media_folder" ]; then - if ! mkdir -p "$media_folder"; then - send_error_message "There was an error creating the installation directory at \"$media_folder\". Make sure you have the necessary permissions ❌" +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_error_message "There was an error creating the installation directory at \"$media_directory\". Make sure you have the necessary permissions ❌" + else + send_success_message "Directory $media_directory created ✅" fi fi -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 ❌" +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 @@ -354,7 +357,7 @@ required information]]" step. #+begin_src bash sed -i -e "s||$puid|g" "$env_file" \ -e "s||$pgid|g" "$env_file" \ - -e "s||$media_folder|g" "$env_file" \ + -e "s||$media_directory|g" "$env_file" \ -e "s||$media_service|g" "$env_file" \ -e "s||$media_service|g" "$filename" @@ -432,7 +435,7 @@ fi 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_folder"; then +if sudo chown -R "$puid":"$pgid" "$media_directory"; then send_success_message "Media folder ownership and permissions set successfully ✅" else send_error_message "Failed to set ownership and permissions for the media folder. Check permissions ❌" diff --git a/install.sh b/install.sh index 7bc5e2d..f17e691 100644 --- a/install.sh +++ b/install.sh @@ -96,20 +96,23 @@ 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"} +read -p "Please, input your media directory [/srv/media]: " media_folder +media_directory=${media_directory:-"/srv/media"} -if [ ! -d "$media_folder" ]; then - if ! mkdir -p "$media_folder"; then - send_error_message "There was an error creating the installation directory at \"$media_folder\". Make sure you have the necessary permissions ❌" +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_error_message "There was an error creating the installation directory at \"$media_directory\". Make sure you have the necessary permissions ❌" + else + send_success_message "Directory $media_directory created ✅" fi fi -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 ❌" +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." @@ -197,7 +200,7 @@ done sed -i -e "s||$puid|g" "$env_file" \ -e "s||$pgid|g" "$env_file" \ - -e "s||$media_folder|g" "$env_file" \ + -e "s||$media_directory|g" "$env_file" \ -e "s||$media_service|g" "$env_file" \ -e "s||$media_service|g" "$filename" @@ -237,7 +240,7 @@ else send_error_message "Failed to install YAMS CLI. Make sure you have the necessary permissions ❌" fi -if sudo chown -R "$puid":"$pgid" "$media_folder"; then +if sudo chown -R "$puid":"$pgid" "$media_directory"; then send_success_message "Media folder ownership and permissions set successfully ✅" else send_error_message "Failed to set ownership and permissions for the media folder. Check permissions ❌" -- cgit v1.2.3 From 403b55a7b9d077191d224488ee7cac6d02183931 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:25:11 -0300 Subject: Added more information messages --- docs.org | 11 +++++++---- install.sh | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs.org b/docs.org index 8efb5bd..b18be18 100644 --- a/docs.org +++ b/docs.org @@ -183,7 +183,10 @@ read -p "Where do you want to install the docker-compose file? [$default_install install_location=${install_location:-$default_install_location} if [ ! -d "$install_location" ]; then - if ! mkdir -p "$install_location"; then + echo "The directory \"$install_location\" does not exists. Attempting to create..." + if mkdir -p "$install_location"; then + send_success_message "Directory $install_location created ✅" + else send_error_message "There was an error creating the installation directory at \"$install_location\". Make sure you have the necessary permissions ❌" fi fi @@ -224,10 +227,10 @@ 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_error_message "There was an error creating the installation directory at \"$media_directory\". Make sure you have the necessary permissions ❌" - else + 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 diff --git a/install.sh b/install.sh index f17e691..f841ac5 100644 --- a/install.sh +++ b/install.sh @@ -77,7 +77,10 @@ read -p "Where do you want to install the docker-compose file? [$default_install install_location=${install_location:-$default_install_location} if [ ! -d "$install_location" ]; then - if ! mkdir -p "$install_location"; then + echo "The directory \"$install_location\" does not exists. Attempting to create..." + if mkdir -p "$install_location"; then + send_success_message "Directory $install_location created ✅" + else send_error_message "There was an error creating the installation directory at \"$install_location\". Make sure you have the necessary permissions ❌" fi fi @@ -104,10 +107,10 @@ 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_error_message "There was an error creating the installation directory at \"$media_directory\". Make sure you have the necessary permissions ❌" - else + 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 -- cgit v1.2.3 From 52c88ed070d52fa50ce21abb8f27010215ed9558 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:27:07 -0300 Subject: Fixed typo --- docs.org | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs.org b/docs.org index b18be18..0500c02 100644 --- a/docs.org +++ b/docs.org @@ -219,7 +219,7 @@ fi :END: #+begin_src bash -read -p "Please, input your media directory [/srv/media]: " media_folder +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 diff --git a/install.sh b/install.sh index f841ac5..b90b66f 100644 --- a/install.sh +++ b/install.sh @@ -99,7 +99,7 @@ else send_error_message "The user \"$username\" doesn't exist!" fi -read -p "Please, input your media directory [/srv/media]: " media_folder +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 -- cgit v1.2.3 From 89405ac84dc6fbb61fb71303cdc60ef4e1db22a9 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:32:07 -0300 Subject: Renamed install_location to install_directory --- docs.org | 52 +++++++++++++++++++++++++++++----------------------- install.sh | 48 +++++++++++++++++++++++++++--------------------- 2 files changed, 56 insertions(+), 44 deletions(-) diff --git a/docs.org b/docs.org index 0500c02..59eff9f 100644 --- a/docs.org +++ b/docs.org @@ -26,7 +26,7 @@ - [[#success-message][Success message!]] - [[#final-steps][Final steps]] - [[#install-the-yams-cli][Install the YAMS CLI]] - - [[#set-the-correct-permissions-to-the-media-folder][Set the correct permissions to the media folder]] + - [[#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]] @@ -179,21 +179,21 @@ fi #+begin_src bash default_install_location="/opt/yams" -read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_location -install_location=${install_location:-$default_install_location} +read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_directory +install_directory=${install_directory:-$default_install_directory} -if [ ! -d "$install_location" ]; then - echo "The directory \"$install_location\" does not exists. Attempting to create..." - if mkdir -p "$install_location"; then - send_success_message "Directory $install_location created ✅" +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_location\". Make sure you have the necessary permissions ❌" + 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_location/docker-compose.yaml" -custom_file_filename="$install_location/docker-compose.custom.yaml" -env_file="$install_location/.env" +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 @@ -315,7 +315,7 @@ if [ "$setup_vpn" == "y" ]; then echo fi -echo "Configuring the docker-compose file for the user \"$username\" on \"$install_location\"..." +echo "Configuring the docker-compose file for the user \"$username\" on \"$install_directory\"..." #+end_src * Installing YAMS @@ -368,7 +368,7 @@ 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_location|g" "$env_file" +sed -i -e "s||$install_directory|g" "$env_file" if [ "$setup_vpn" == "y" ]; then sed -i -e "s||$vpn_service|g" "$env_file" \ @@ -390,7 +390,7 @@ fi #+begin_src bash sed -i -e "s||$filename|g" yams \ -e "s||$custom_file_filename|g" yams \ - -e "s||$install_location|g" yams + -e "s||$install_directory|g" yams #+end_src ** Success message! @@ -430,7 +430,7 @@ else fi #+end_src -** Set the correct permissions to the media folder +** Set the correct permissions to the media and install directories :PROPERTIES: :ID: 4cfb9397-776d-46db-84cc-54b78395cba8 :END: @@ -439,9 +439,15 @@ This adds the correct permissions to the media folder, in case they are not corr #+begin_src bash if sudo chown -R "$puid":"$pgid" "$media_directory"; then - send_success_message "Media folder ownership and permissions set successfully ✅" + send_success_message "Media directory ownership and permissions set successfully ✅" else - send_error_message "Failed to set ownership and permissions for the media folder. Check permissions ❌" + 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 @@ -454,17 +460,17 @@ This is where all the configurations are going to be saved. If it doesn't it wil it can't be created, we'll raise an error. #+begin_src bash -if [[ -d "$install_location/config" ]]; then - send_success_message "Configuration folder \"$install_location/config\" exists ✅" +if [[ -d "$install_directory/config" ]]; then + send_success_message "Configuration folder \"$install_directory/config\" exists ✅" else - if sudo mkdir -p "$install_location/config"; then - send_success_message "Configuration folder \"$install_location/config\" created ✅" + 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_location/config"; then +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 ❌" @@ -493,7 +499,7 @@ echo " \__\/ \ \::/ \ \:\ \ \::/ " echo " \__\/ \__\/ \__\/ " echo "========================================================" send_success_message "All done!✅ Enjoy YAMS!" -echo "You can check the installation on $install_location" +echo "You can check the installation on $install_directory" echo "========================================================" echo "Everything should be running now! To check everything running, go to:" echo diff --git a/install.sh b/install.sh index b90b66f..cdecb73 100644 --- a/install.sh +++ b/install.sh @@ -73,21 +73,21 @@ fi default_install_location="/opt/yams" -read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_location -install_location=${install_location:-$default_install_location} +read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_directory +install_directory=${install_directory:-$default_install_directory} -if [ ! -d "$install_location" ]; then - echo "The directory \"$install_location\" does not exists. Attempting to create..." - if mkdir -p "$install_location"; then - send_success_message "Directory $install_location created ✅" +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_location\". Make sure you have the necessary permissions ❌" + 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_location/docker-compose.yaml" -custom_file_filename="$install_location/docker-compose.custom.yaml" -env_file="$install_location/.env" +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} @@ -181,7 +181,7 @@ if [ "$setup_vpn" == "y" ]; then echo fi -echo "Configuring the docker-compose file for the user \"$username\" on \"$install_location\"..." +echo "Configuring the docker-compose file for the user \"$username\" on \"$install_directory\"..." copy_files=( "docker-compose.example.yaml:$filename" @@ -211,7 +211,7 @@ 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_location|g" "$env_file" +sed -i -e "s||$install_directory|g" "$env_file" if [ "$setup_vpn" == "y" ]; then sed -i -e "s||$vpn_service|g" "$env_file" \ @@ -226,7 +226,7 @@ fi sed -i -e "s||$filename|g" yams \ -e "s||$custom_file_filename|g" yams \ - -e "s||$install_location|g" yams + -e "s||$install_directory|g" yams send_success_message "Everything installed correctly! 🎉" @@ -244,22 +244,28 @@ else fi if sudo chown -R "$puid":"$pgid" "$media_directory"; then - send_success_message "Media folder ownership and permissions set successfully ✅" + send_success_message "Media directory ownership and permissions set successfully ✅" else - send_error_message "Failed to set ownership and permissions for the media folder. Check permissions ❌" + send_error_message "Failed to set ownership and permissions for the media directory. Check permissions ❌" fi -if [[ -d "$install_location/config" ]]; then - send_success_message "Configuration folder \"$install_location/config\" exists ✅" +if sudo chown -R "$puid":"$pgid" "$install_directory"; then + send_success_message "Install directory ownership and permissions set successfully ✅" else - if sudo mkdir -p "$install_location/config"; then - send_success_message "Configuration folder \"$install_location/config\" created ✅" + 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_location/config"; then +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 ❌" @@ -281,7 +287,7 @@ echo " \__\/ \ \::/ \ \:\ \ \::/ " echo " \__\/ \__\/ \__\/ " echo "========================================================" send_success_message "All done!✅ Enjoy YAMS!" -echo "You can check the installation on $install_location" +echo "You can check the installation on $install_directory" echo "========================================================" echo "Everything should be running now! To check everything running, go to:" echo -- cgit v1.2.3 From 9014e10cc1605dc1ff2a10991c77fb720fad80e8 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:33:56 -0300 Subject: Fixed typo --- docs.org | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs.org b/docs.org index 59eff9f..d7f9606 100644 --- a/docs.org +++ b/docs.org @@ -177,7 +177,7 @@ fi :END: #+begin_src bash -default_install_location="/opt/yams" +default_install_directory="/opt/yams" read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_directory install_directory=${install_directory:-$default_install_directory} diff --git a/install.sh b/install.sh index cdecb73..35df052 100644 --- a/install.sh +++ b/install.sh @@ -71,7 +71,7 @@ if [[ "$EUID" = 0 ]]; then send_error_message "YAMS has to run without sudo! Please, run it again with regular permissions" fi -default_install_location="/opt/yams" +default_install_directory="/opt/yams" read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_directory install_directory=${install_directory:-$default_install_directory} -- cgit v1.2.3 From 18d37584fec24d9496a7524b58d746a305955167 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:36:39 -0300 Subject: Fixed typo --- docs.org | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs.org b/docs.org index d7f9606..4640926 100644 --- a/docs.org +++ b/docs.org @@ -179,7 +179,7 @@ fi #+begin_src bash default_install_directory="/opt/yams" -read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_directory +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 diff --git a/install.sh b/install.sh index 35df052..eb02686 100644 --- a/install.sh +++ b/install.sh @@ -73,7 +73,7 @@ fi default_install_directory="/opt/yams" -read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_directory +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 -- cgit v1.2.3 From 27284eddae5a3a486e3c67794a5cfd29d9f6ab15 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:40:12 -0300 Subject: Fixed bad environemnt variable --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index b137255..f2e98c3 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,7 @@ PUID= PGID= MEDIA_DIRECTORY= -INSTALL_LOCATION= +INSTALL_LOCATION= MEDIA_SERVICE= # VPN configuration -- cgit v1.2.3 From eb13d6e0da36824e31550084da92efcffd869f13 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:46:51 -0300 Subject: Extra small refactors --- docs.org | 38 ++++++++++++++++++++++++-------------- install.sh | 38 ++++++++++++++++++++++++-------------- 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/docs.org b/docs.org index 4640926..da44753 100644 --- a/docs.org +++ b/docs.org @@ -110,12 +110,12 @@ This function verifies that the dependencies are installed. ~Docker~ and ~docker for YAMS to work. #+begin_src bash -check_dependencides() { - if command -v $1 &> /dev/null; then - send_success_message "$1 exists ✅ " +check_dependencies() { + 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 + echo -e "\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 @@ -138,15 +138,25 @@ finish installing. #+begin_src bash 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/" + + 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 diff --git a/install.sh b/install.sh index eb02686..6b29335 100644 --- a/install.sh +++ b/install.sh @@ -32,12 +32,12 @@ send_error_message() { exit 255 } -check_dependencides() { - if command -v $1 &> /dev/null; then - send_success_message "$1 exists ✅ " +check_dependencies() { + 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 + echo -e "\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 @@ -50,15 +50,25 @@ check_dependencides() { 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/" + + 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..." -- cgit v1.2.3 From a0486d9f6b5606f0b8aa0d175d84c1c55a684076 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:53:55 -0300 Subject: Fixed unreachable bug --- docs.org | 8 ++++---- install.sh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs.org b/docs.org index da44753..0109f71 100644 --- a/docs.org +++ b/docs.org @@ -110,12 +110,12 @@ This function verifies that the dependencies are installed. ~Docker~ and ~docker for YAMS to work. #+begin_src bash -check_dependencies() { +check_dependencides() { if command -v "$1" &> /dev/null; then - send_success_message "$1 exists ✅" + send_success_message "$1 exists ✅ " else - echo -e "\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 + 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 diff --git a/install.sh b/install.sh index 6b29335..802a395 100644 --- a/install.sh +++ b/install.sh @@ -32,12 +32,12 @@ send_error_message() { exit 255 } -check_dependencies() { +check_dependencides() { if command -v "$1" &> /dev/null; then - send_success_message "$1 exists ✅" + send_success_message "$1 exists ✅ " else - echo -e "\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 + 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 -- cgit v1.2.3 From aee33be7a0d137dcd1c9cbc7e959413d1114725e Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 21 Oct 2023 18:59:41 -0300 Subject: Created automatic install script --- docs.org | 2 +- install.sh | 318 +------------------------------------------------------------ setup.sh | 317 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 321 insertions(+), 316 deletions(-) mode change 100644 => 100755 install.sh create mode 100644 setup.sh diff --git a/docs.org b/docs.org index 0109f71..301c4e0 100644 --- a/docs.org +++ b/docs.org @@ -1,5 +1,5 @@ #+title: Docs -#+PROPERTY: header-args :tangle install.sh +#+PROPERTY: header-args :tangle setup.sh #+auto_tangle: t * Table of contents :toc: diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 802a395..2b92f65 --- a/install.sh +++ b/install.sh @@ -1,317 +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 "" - -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||$puid|g" "$env_file" \ - -e "s||$pgid|g" "$env_file" \ - -e "s||$media_directory|g" "$env_file" \ - -e "s||$media_service|g" "$env_file" \ - -e "s||$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|g" "$env_file" - -if [ "$setup_vpn" == "y" ]; then - sed -i -e "s||$vpn_service|g" "$env_file" \ - -e "s||$vpn_user|g" "$env_file" \ - -e "s||$vpn_password|g" "$env_file" \ - -e "s||$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|g" yams \ - -e "s||$custom_file_filename|g" yams \ - -e "s||$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 +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 diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..802a395 --- /dev/null +++ b/setup.sh @@ -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||$puid|g" "$env_file" \ + -e "s||$pgid|g" "$env_file" \ + -e "s||$media_directory|g" "$env_file" \ + -e "s||$media_service|g" "$env_file" \ + -e "s||$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|g" "$env_file" + +if [ "$setup_vpn" == "y" ]; then + sed -i -e "s||$vpn_service|g" "$env_file" \ + -e "s||$vpn_user|g" "$env_file" \ + -e "s||$vpn_password|g" "$env_file" \ + -e "s||$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|g" yams \ + -e "s||$custom_file_filename|g" yams \ + -e "s||$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 -- cgit v1.2.3