Upgraded YAMS version to v2.0 #60

Merged
rogs merged 32 commits from v2 into master 2023-10-21 22:02:31 -03:00
2 changed files with 75 additions and 80 deletions
Showing only changes of commit 612eb32cd8 - Show all commits

View File

@ -15,7 +15,8 @@
- [[#verify-all-the-dependencies][Verify all the dependencies]] - [[#verify-all-the-dependencies][Verify all the dependencies]]
- [[#gather-all-the-required-information][Gather all the required information]] - [[#gather-all-the-required-information][Gather all the required information]]
- [[#checking-install-location][Checking install location]] - [[#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-perferred-media-service][Setting perferred media service]]
- [[#setting-the-vpn][Setting the VPN]] - [[#setting-the-vpn][Setting the VPN]]
- [[#installing-yams][Installing YAMS]] - [[#installing-yams][Installing YAMS]]
@ -25,7 +26,7 @@
- [[#success-message][Success message!]] - [[#success-message][Success message!]]
- [[#final-steps][Final steps]] - [[#final-steps][Final steps]]
- [[#install-the-yams-cli][Install the YAMS CLI]] - [[#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]] - [[#create-the-config-directory][Create the config directory]]
- [[#display-closing-message][Display closing message]] - [[#display-closing-message][Display closing message]]
@ -176,17 +177,29 @@ fi
:END: :END:
#+begin_src bash #+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" filename="$install_location/docker-compose.yaml"
custom_file_filename="$install_location/docker-compose.custom.yaml" custom_file_filename="$install_location/docker-compose.custom.yaml"
env_file="$install_location/.env" env_file="$install_location/.env"
#+end_src
** Setting the correct user
:PROPERTIES:
:ID: 7428d7b7-aec5-4638-b370-84e9055fb412
:END:
#+begin_src bash
read -p "What's the user that is going to own the media server files? [$USER]: " username read -p "What's the user that is going to own the media server files? [$USER]: " username
username=${username:-$USER} username=${username:-$USER}
if id -u "$username" &>/dev/null; then if id -u "$username" &>/dev/null; then
@ -195,26 +208,26 @@ if id -u "$username" &>/dev/null; then
else else
send_error_message "The user \"$username\" doesn't exist!" send_error_message "The user \"$username\" doesn't exist!"
fi fi
read -p "Please, input your media folder [/srv/media]: " media_folder
media_folder=${media_folder:-"/srv/media"}
#+end_src #+end_src
** Verify media folder ** Media directory
:PROPERTIES: :PROPERTIES:
:ID: 9726dead-8833-4f23-98b8-2790d72605de :ID: 9726dead-8833-4f23-98b8-2790d72605de
:END: :END:
#+begin_src bash #+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 read -p "Are you sure your media folder is \"$media_folder\"? [y/N]: " media_folder_correct
media_folder_correct=${media_folder_correct:-"n"} media_folder_correct=${media_folder_correct:-"n"}
if [ "$media_folder_correct" == "n" ]; then 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 fi
#+end_src #+end_src
@ -224,18 +237,16 @@ fi
:END: :END:
#+begin_src bash #+begin_src bash
echo echo -e "\n\n\nTime to choose your media service."
echo echo "Your media service is responsible for serving your files to your network."
echo echo "By default, YAMS supports 3 media services:"
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 "- jellyfin (recommended, easier)"
echo "- emby" echo "- emby"
echo "- plex (advanced, always online)" echo "- plex (advanced, always online)"
read -p "Choose your media service [jellyfin]: " media_service read -p "Choose your media service [jellyfin]: " media_service
media_service=${media_service:-"jellyfin"} 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 media_service_port=8096
if [ "$media_service" == "plex" ]; then if [ "$media_service" == "plex" ]; then
@ -243,7 +254,7 @@ if [ "$media_service" == "plex" ]; then
fi fi
if echo "emby plex jellyfin" | grep -qw "$media_service"; then 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 else
send_error_message "\"$media_service\" is not supported by YAMS. Are you sure you chose the correct service?" send_error_message "\"$media_service\" is not supported by YAMS. Are you sure you chose the correct service?"
fi fi
@ -255,21 +266,19 @@ fi
:END: :END:
#+begin_src bash #+begin_src bash
echo echo -e "\nTime to set up the VPN."
echo
echo
echo "Time to set up the VPN."
echo "You can check the supported VPN list here: https://yams.media/advanced/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 read -p "Do you want to configure a VPN? [Y/n]: " setup_vpn
setup_vpn=${setup_vpn:-"y"} setup_vpn=${setup_vpn:-"y"}
if [ "$setup_vpn" == "y" ]; then if [ "$setup_vpn" == "y" ]; then
read -p "What's your VPN service? (with spaces) [mullvad]: " vpn_service read -p "What's your VPN service? (with spaces) [mullvad]: " vpn_service
vpn_service=${vpn_service:-"mullvad"} 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 "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 read -p "What's your VPN username? (without spaces): " vpn_user
unset vpn_password unset vpn_password
@ -322,12 +331,16 @@ for file_mapping in "${copy_files[@]}"; do
destination_file="${file_mapping##*:}" destination_file="${file_mapping##*:}"
echo -e "\nCopying $source_file to $destination_file..." echo -e "\nCopying $source_file to $destination_file..."
if ! cp "$source_file" "$destination_file"; then 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." 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 fi
done done
#+end_src #+end_src
#+RESULTS:
** 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
:PROPERTIES: :PROPERTIES:
:ID: 3d169001-f0f7-477f-a954-0460484f4b43 :ID: 3d169001-f0f7-477f-a954-0460484f4b43
@ -409,25 +422,14 @@ else
fi fi
#+end_src #+end_src
** Create and set the correct permissions to the media folder ** Set the correct permissions to the media folder
:PROPERTIES: :PROPERTIES:
:ID: 4cfb9397-776d-46db-84cc-54b78395cba8 :ID: 4cfb9397-776d-46db-84cc-54b78395cba8
:END: :END:
Now, we validate the media folder exists. If it doesn't we'll try and create it. If it can't be created, This adds the correct permissions to the media folder, in case they are not correct.
it will raise an error.
#+begin_src bash #+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 if sudo chown -R "$puid":"$pgid" "$media_folder"; then
send_success_message "Media folder ownership and permissions set successfully ✅" send_success_message "Media folder ownership and permissions set successfully ✅"
else else

View File

@ -71,17 +71,22 @@ if [[ "$EUID" = 0 ]]; then
send_error_message "YAMS has to run without sudo! Please, run it again with regular permissions" send_error_message "YAMS has to run without sudo! Please, run it again with regular permissions"
fi 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" filename="$install_location/docker-compose.yaml"
custom_file_filename="$install_location/docker-compose.custom.yaml" custom_file_filename="$install_location/docker-compose.custom.yaml"
env_file="$install_location/.env" env_file="$install_location/.env"
read -p "What's the user that is going to own the media server files? [$USER]: " username read -p "What's the user that is going to own the media server files? [$USER]: " username
username=${username:-$USER} username=${username:-$USER}
if id -u "$username" &>/dev/null; then if id -u "$username" &>/dev/null; then
@ -94,29 +99,27 @@ fi
read -p "Please, input your media folder [/srv/media]: " media_folder read -p "Please, input your media folder [/srv/media]: " media_folder
media_folder=${media_folder:-"/srv/media"} 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!" if [ ! -d "$media_folder" ]; then
send_error_message "The directory \"$media_folder\" does not exist!"
media_folder=$(realpath "$media_folder") fi
read -p "Are you sure your media folder is \"$media_folder\"? [y/N]: " media_folder_correct read -p "Are you sure your media folder is \"$media_folder\"? [y/N]: " media_folder_correct
media_folder_correct=${media_folder_correct:-"n"} media_folder_correct=${media_folder_correct:-"n"}
if [ "$media_folder_correct" == "n" ]; then 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 fi
echo echo -e "\n\n\nTime to choose your media service."
echo echo "Your media service is responsible for serving your files to your network."
echo echo "By default, YAMS supports 3 media services:"
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 "- jellyfin (recommended, easier)"
echo "- emby" echo "- emby"
echo "- plex (advanced, always online)" echo "- plex (advanced, always online)"
read -p "Choose your media service [jellyfin]: " media_service read -p "Choose your media service [jellyfin]: " media_service
media_service=${media_service:-"jellyfin"} 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 media_service_port=8096
if [ "$media_service" == "plex" ]; then if [ "$media_service" == "plex" ]; then
@ -124,26 +127,24 @@ if [ "$media_service" == "plex" ]; then
fi fi
if echo "emby plex jellyfin" | grep -qw "$media_service"; then 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 else
send_error_message "\"$media_service\" is not supported by YAMS. Are you sure you chose the correct service?" send_error_message "\"$media_service\" is not supported by YAMS. Are you sure you chose the correct service?"
fi fi
echo echo -e "\nTime to set up the VPN."
echo
echo
echo "Time to set up the VPN."
echo "You can check the supported VPN list here: https://yams.media/advanced/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 read -p "Do you want to configure a VPN? [Y/n]: " setup_vpn
setup_vpn=${setup_vpn:-"y"} setup_vpn=${setup_vpn:-"y"}
if [ "$setup_vpn" == "y" ]; then if [ "$setup_vpn" == "y" ]; then
read -p "What's your VPN service? (with spaces) [mullvad]: " vpn_service read -p "What's your VPN service? (with spaces) [mullvad]: " vpn_service
vpn_service=${vpn_service:-"mullvad"} 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 "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 read -p "What's your VPN username? (without spaces): " vpn_user
unset vpn_password unset vpn_password
@ -185,8 +186,10 @@ for file_mapping in "${copy_files[@]}"; do
destination_file="${file_mapping##*:}" destination_file="${file_mapping##*:}"
echo -e "\nCopying $source_file to $destination_file..." echo -e "\nCopying $source_file to $destination_file..."
if ! cp "$source_file" "$destination_file"; then 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." 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 fi
done done
@ -232,16 +235,6 @@ 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 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 if sudo chown -R "$puid":"$pgid" "$media_folder"; then
send_success_message "Media folder ownership and permissions set successfully ✅" send_success_message "Media folder ownership and permissions set successfully ✅"
else else