Refactored YAMS to literate #59

Merged
rogs merged 32 commits from feature/refactor-to-literate into v2 2023-10-21 19:17:08 -03:00
2 changed files with 56 additions and 44 deletions
Showing only changes of commit 89405ac84d - Show all commits

View File

@ -26,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]]
- [[#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]] - [[#create-the-config-directory][Create the config directory]]
- [[#display-closing-message][Display closing message]] - [[#display-closing-message][Display closing message]]
@ -179,21 +179,21 @@ fi
#+begin_src bash #+begin_src bash
default_install_location="/opt/yams" default_install_location="/opt/yams"
read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_location read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_directory
install_location=${install_location:-$default_install_location} install_directory=${install_directory:-$default_install_directory}
if [ ! -d "$install_location" ]; then if [ ! -d "$install_directory" ]; then
echo "The directory \"$install_location\" does not exists. Attempting to create..." echo "The directory \"$install_directory\" does not exists. Attempting to create..."
if mkdir -p "$install_location"; then if mkdir -p "$install_directory"; then
send_success_message "Directory $install_location created ✅" send_success_message "Directory $install_directory created ✅"
else 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
fi fi
filename="$install_location/docker-compose.yaml" filename="$install_directory/docker-compose.yaml"
custom_file_filename="$install_location/docker-compose.custom.yaml" custom_file_filename="$install_directory/docker-compose.custom.yaml"
env_file="$install_location/.env" env_file="$install_directory/.env"
#+end_src #+end_src
** Setting the correct user ** Setting the correct user
@ -315,7 +315,7 @@ if [ "$setup_vpn" == "y" ]; then
echo echo
fi 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 #+end_src
* Installing YAMS * 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" sed -i -e "s|#network_mode: host # plex|network_mode: host # plex|g" "$filename"
fi fi
sed -i -e "s|<install_location>|$install_location|g" "$env_file" sed -i -e "s|<install_directory>|$install_directory|g" "$env_file"
if [ "$setup_vpn" == "y" ]; then if [ "$setup_vpn" == "y" ]; then
sed -i -e "s|<vpn_service>|$vpn_service|g" "$env_file" \ sed -i -e "s|<vpn_service>|$vpn_service|g" "$env_file" \
@ -390,7 +390,7 @@ fi
#+begin_src bash #+begin_src bash
sed -i -e "s|<filename>|$filename|g" yams \ sed -i -e "s|<filename>|$filename|g" yams \
-e "s|<custom_file_filename>|$custom_file_filename|g" yams \ -e "s|<custom_file_filename>|$custom_file_filename|g" yams \
-e "s|<install_location>|$install_location|g" yams -e "s|<install_directory>|$install_directory|g" yams
#+end_src #+end_src
** Success message! ** Success message!
@ -430,7 +430,7 @@ else
fi fi
#+end_src #+end_src
** Set the correct permissions to the media folder ** Set the correct permissions to the media and install directories
:PROPERTIES: :PROPERTIES:
:ID: 4cfb9397-776d-46db-84cc-54b78395cba8 :ID: 4cfb9397-776d-46db-84cc-54b78395cba8
:END: :END:
@ -439,9 +439,15 @@ This adds the correct permissions to the media folder, in case they are not corr
#+begin_src bash #+begin_src bash
if sudo chown -R "$puid":"$pgid" "$media_directory"; then 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 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 fi
#+end_src #+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. it can't be created, we'll raise an error.
#+begin_src bash #+begin_src bash
if [[ -d "$install_location/config" ]]; then if [[ -d "$install_directory/config" ]]; then
send_success_message "Configuration folder \"$install_location/config\" exists ✅" send_success_message "Configuration folder \"$install_directory/config\" exists ✅"
else else
if sudo mkdir -p "$install_location/config"; then if sudo mkdir -p "$install_directory/config"; then
send_success_message "Configuration folder \"$install_location/config\" created ✅" send_success_message "Configuration folder \"$install_directory/config\" created ✅"
else 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
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 ✅" send_success_message "Configuration folder ownership and permissions set successfully ✅"
else 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 ❌"
@ -493,7 +499,7 @@ echo " \__\/ \ \::/ \ \:\ \ \::/ "
echo " \__\/ \__\/ \__\/ " echo " \__\/ \__\/ \__\/ "
echo "========================================================" echo "========================================================"
send_success_message "All done!✅ Enjoy YAMS!" 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 "========================================================"
echo "Everything should be running now! To check everything running, go to:" echo "Everything should be running now! To check everything running, go to:"
echo echo

View File

@ -73,21 +73,21 @@ fi
default_install_location="/opt/yams" default_install_location="/opt/yams"
read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_location read -p "Where do you want to install the docker-compose file? [$default_install_location]: " install_directory
install_location=${install_location:-$default_install_location} install_directory=${install_directory:-$default_install_directory}
if [ ! -d "$install_location" ]; then if [ ! -d "$install_directory" ]; then
echo "The directory \"$install_location\" does not exists. Attempting to create..." echo "The directory \"$install_directory\" does not exists. Attempting to create..."
if mkdir -p "$install_location"; then if mkdir -p "$install_directory"; then
send_success_message "Directory $install_location created ✅" send_success_message "Directory $install_directory created ✅"
else 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
fi fi
filename="$install_location/docker-compose.yaml" filename="$install_directory/docker-compose.yaml"
custom_file_filename="$install_location/docker-compose.custom.yaml" custom_file_filename="$install_directory/docker-compose.custom.yaml"
env_file="$install_location/.env" env_file="$install_directory/.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}
@ -181,7 +181,7 @@ if [ "$setup_vpn" == "y" ]; then
echo echo
fi 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=( copy_files=(
"docker-compose.example.yaml:$filename" "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" sed -i -e "s|#network_mode: host # plex|network_mode: host # plex|g" "$filename"
fi fi
sed -i -e "s|<install_location>|$install_location|g" "$env_file" sed -i -e "s|<install_directory>|$install_directory|g" "$env_file"
if [ "$setup_vpn" == "y" ]; then if [ "$setup_vpn" == "y" ]; then
sed -i -e "s|<vpn_service>|$vpn_service|g" "$env_file" \ sed -i -e "s|<vpn_service>|$vpn_service|g" "$env_file" \
@ -226,7 +226,7 @@ fi
sed -i -e "s|<filename>|$filename|g" yams \ sed -i -e "s|<filename>|$filename|g" yams \
-e "s|<custom_file_filename>|$custom_file_filename|g" yams \ -e "s|<custom_file_filename>|$custom_file_filename|g" yams \
-e "s|<install_location>|$install_location|g" yams -e "s|<install_directory>|$install_directory|g" yams
send_success_message "Everything installed correctly! 🎉" send_success_message "Everything installed correctly! 🎉"
@ -244,22 +244,28 @@ else
fi fi
if sudo chown -R "$puid":"$pgid" "$media_directory"; then 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 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 fi
if [[ -d "$install_location/config" ]]; then if sudo chown -R "$puid":"$pgid" "$install_directory"; then
send_success_message "Configuration folder \"$install_location/config\" exists ✅" send_success_message "Install directory ownership and permissions set successfully ✅"
else else
if sudo mkdir -p "$install_location/config"; then send_error_message "Failed to set ownership and permissions for the install directory. Check permissions ❌"
send_success_message "Configuration folder \"$install_location/config\" created ✅" 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 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
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 ✅" send_success_message "Configuration folder ownership and permissions set successfully ✅"
else 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 ❌"
@ -281,7 +287,7 @@ echo " \__\/ \ \::/ \ \:\ \ \::/ "
echo " \__\/ \__\/ \__\/ " echo " \__\/ \__\/ \__\/ "
echo "========================================================" echo "========================================================"
send_success_message "All done!✅ Enjoy YAMS!" 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 "========================================================"
echo "Everything should be running now! To check everything running, go to:" echo "Everything should be running now! To check everything running, go to:"
echo echo