diff --git a/installer.sh b/installer.sh index 9e757df..1e92465 100755 --- a/installer.sh +++ b/installer.sh @@ -61,15 +61,38 @@ _success() { printf "\n%s✓ Success:%s\n" "$(tput setaf 2)" "$(tput sgr0) $1" } +cecho -c 'blue' "***************************************" cecho -c 'blue' "Welcome to the RPi Dashboard installer!" -read -p "This setup assumes you have a working web server installed that is up and running. Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 +cecho -c 'blue' "***************************************" +if ! command -v git >/dev/null; then + echo "${RED}Git is not installed. Please install Git to continue.${RESET}" + exit 1 +fi +read -p "Attention! By continuing you confirm having a working web server (Lighttpd / Apache) with PHP (5+) setup that is properly configured and running. Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 hostn="`hostname`" -cecho -c 'blue' "This setup will install the dashboard to /var/www/html." -_process "Please choose your subfolder name, so you will be able to call the dashboard at http://$hostn/{your_subfolder_name}" -read -p "Enter custom subfolder name: " subfoldern -cd /var/www/html -git clone https://github.com/femto-code/Raspberry-Pi-Dashboard $subfoldern -_process "Setting up valid permissions for /var/www/html/$subfoldern..." -sudo chown -R ${whoami}:www-data /var/www/html/$subfoldern -sudo chmod -R 775 /var/www/html/$subfoldern -_success "Installation done! To access the dashboard open up a web browser with URL: http://$hostn/$subfoldern" +cecho -c 'blue' "This setup will install the RPi Dashboard to -> /var/www/html/" +_process "Please choose a subfolder name. This name will be part of the address http://$hostn/{your_subfolder_name} with which you can access your RPi dashboard within your local network." + +subfoldern="" +while [[ -z "$subfoldern" ]]; do + read -p "Enter custom subfolder name: " subfoldern + subfoldern=$(echo $subfoldern | xargs) + if [[ -z "$subfoldern" ]]; then + echo "${RED}Please enter a valid subfolder name.${RESET}" + fi +done +_process "Creating subfolder /var/www/html/$subfoldern ..." +mkdir -p /var/www/html/$subfoldern +# Check if mkdir succeeded +if [ $? -ne 0 ]; then + echo + echo "${RED}Failed to create sub-directory for the RPi Dashboard!${RESET}" + echo "${YELLOW}Please make sure that the folder /var/www/html/ exists (if not, make sure a web server is installed first) and that you have necessary permissions to write into that folder.${RESET}" + exit 1 +fi +git clone https://github.com/femto-code/Raspberry-Pi-Dashboard /var/www/html/$subfoldern +_process "Setting up valid permissions for /var/www/html/$subfoldern ..." +chown -R ${whoami}:www-data /var/www/html/$subfoldern +chmod -R 775 /var/www/html/$subfoldern +_success "Installation done! To access the newly installed RPi dashboard open up a web browser and access URL: http://$hostn/$subfoldern !" +_process "Please report any issues here: https://github.com/femto-code/Raspberry-Pi-Dashboard/issues. Thank you!" \ No newline at end of file