summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Gonzalez <roger@rogs.me>2023-10-21 18:12:03 -0300
committerRoger Gonzalez <roger@rogs.me>2023-10-21 18:12:03 -0300
commit612eb32cd880364f8ae75ff7b7f9ed1634ee5763 (patch)
treed6fcacfcd50390b8d0af753a03afdf542ef98724
parent63a453951ef703a0408876889fae469ab41472e2 (diff)
Refactored the information gathering section
-rw-r--r--docs.org90
-rw-r--r--install.sh65
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