Skip to content

Commit f138217

Browse files
committed
Update installer.sh
1 parent 525e2cb commit f138217

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

installer.sh

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,38 @@ _success() {
6161
printf "\n%s✓ Success:%s\n" "$(tput setaf 2)" "$(tput sgr0) $1"
6262
}
6363

64+
cecho -c 'blue' "***************************************"
6465
cecho -c 'blue' "Welcome to the RPi Dashboard installer!"
65-
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
66+
cecho -c 'blue' "***************************************"
67+
if ! command -v git >/dev/null; then
68+
echo "${RED}Git is not installed. Please install Git to continue.${RESET}"
69+
exit 1
70+
fi
71+
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
6672
hostn="`hostname`"
67-
cecho -c 'blue' "This setup will install the dashboard to /var/www/html."
68-
_process "Please choose your subfolder name, so you will be able to call the dashboard at http://$hostn/{your_subfolder_name}"
69-
read -p "Enter custom subfolder name: " subfoldern
70-
cd /var/www/html
71-
git clone https://github.com/femto-code/Raspberry-Pi-Dashboard $subfoldern
72-
_process "Setting up valid permissions for /var/www/html/$subfoldern..."
73-
sudo chown -R ${whoami}:www-data /var/www/html/$subfoldern
74-
sudo chmod -R 775 /var/www/html/$subfoldern
75-
_success "Installation done! To access the dashboard open up a web browser with URL: http://$hostn/$subfoldern"
73+
cecho -c 'blue' "This setup will install the RPi Dashboard to -> /var/www/html/"
74+
_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."
75+
76+
subfoldern=""
77+
while [[ -z "$subfoldern" ]]; do
78+
read -p "Enter custom subfolder name: " subfoldern
79+
subfoldern=$(echo $subfoldern | xargs)
80+
if [[ -z "$subfoldern" ]]; then
81+
echo "${RED}Please enter a valid subfolder name.${RESET}"
82+
fi
83+
done
84+
_process "Creating subfolder /var/www/html/$subfoldern ..."
85+
mkdir -p /var/www/html/$subfoldern
86+
# Check if mkdir succeeded
87+
if [ $? -ne 0 ]; then
88+
echo
89+
echo "${RED}Failed to create sub-directory for the RPi Dashboard!${RESET}"
90+
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}"
91+
exit 1
92+
fi
93+
git clone https://github.com/femto-code/Raspberry-Pi-Dashboard /var/www/html/$subfoldern
94+
_process "Setting up valid permissions for /var/www/html/$subfoldern ..."
95+
chown -R ${whoami}:www-data /var/www/html/$subfoldern
96+
chmod -R 775 /var/www/html/$subfoldern
97+
_success "Installation done! To access the newly installed RPi dashboard open up a web browser and access URL: http://$hostn/$subfoldern !"
98+
_process "Please report any issues here: https://github.com/femto-code/Raspberry-Pi-Dashboard/issues. Thank you!"

0 commit comments

Comments
 (0)