From 71bf327f56b7115a95946352ea4b878929d6f921 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 6 May 2022 03:02:26 -0500 Subject: [PATCH 1/8] gui/install.sh: fix permissions Files should be 644, not 775. --- gui/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/install.sh b/gui/install.sh index 472433d1a..bc7cd78b4 100755 --- a/gui/install.sh +++ b/gui/install.sh @@ -167,7 +167,8 @@ fi echo -e "${GREEN}* Retrieving github files to build admin portal${NC}" git clone https://github.com/thomasjacquin/allsky-portal.git "${PORTAL_DIR}" chown -R ${SUDO_USER}:www-data "${PORTAL_DIR}" -chmod -R 775 "${PORTAL_DIR}" +find "${PORTAL_DIR}/" -type f -exec chmod 644 {} \; +find "${PORTAL_DIR}/" -type d -exec chmod 775 {} \; # Restore WEBSITE_DIR if it existed before if [ "${TMP_WEBSITE_DIR}" != "" ]; then From 815a7d2e6858cbf60186236eb67d11909d1e38a7 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 6 May 2022 03:04:07 -0500 Subject: [PATCH 2/8] sudoers: add ifconfig - bug fix ifconfig needs to be in the file in order for the start/stop network buttons in the WebUI to work. --- gui/sudoers | 1 + 1 file changed, 1 insertion(+) diff --git a/gui/sudoers b/gui/sudoers index e57613715..c6a64a022 100644 --- a/gui/sudoers +++ b/gui/sudoers @@ -25,3 +25,4 @@ www-data ALL=(ALL) NOPASSWD:/bin/cp www-data ALL=(ALL) NOPASSWD:/bin/mv www-data ALL=(ALL) NOPASSWD:/usr/bin/vcgencmd www-data ALL=(ALL) NOPASSWD:XX_ALLSKY_SCRIPTS_XX/postData.sh +www-data ALL=(ALL) NOPASSWD:/usr/sbin/ifconfig From e55a5e86f120286685e603af8f3cc8e9a5bad6e1 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 6 May 2022 03:14:10 -0500 Subject: [PATCH 3/8] lighttpd.conf 2 fixes 1. Add the "thumbnails" directory to the list where buffering is turned off. Without this, new thumbnails didn't appear until ALL of them were created, and with video thumbnails that could be half a minute, and the user would think the page hung. 2. Remove the "compress" lines since we aren't doing compression. With the lines there, it produces two warnings in the log file. --- gui/lighttpd.conf | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gui/lighttpd.conf b/gui/lighttpd.conf index 970de7b9e..e336b81e6 100644 --- a/gui/lighttpd.conf +++ b/gui/lighttpd.conf @@ -17,7 +17,7 @@ server.port = 80 dir-listing.activate = "enable" -$HTTP["url"] =~ "allsky/videos|allsky/startrails|allsky/keograms" { +$HTTP["url"] =~ "thumbnails|allsky/videos|allsky/startrails|allsky/keograms" { server.stream-response-body = 1 } else $HTTP["url"] =~ "^/current" { expire.url = ( "" => "access plus 0 seconds") @@ -50,9 +50,6 @@ index-file.names = ( "index.php", "index.html" ) url.access-deny = ( "~", ".inc" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) -compress.cache-dir = "/var/cache/lighttpd/compress/" -compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) - #mimetype.assign = (".css" => "text/css", ) # default listening port for IPv6 falls back to the IPv4 port From ead954644aafaa0002b4fa042dd3a4c20543409b Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 6 May 2022 03:21:09 -0500 Subject: [PATCH 4/8] install.sh: misc changes * Put { } around variables to be consistent. * Add quotes around some variables. * No longer any need to replace only the FIRST instance of XX_ALLSKY_HOME_XX in funciton.php, so removed that comment and code. * Merged the "sed -i" statements from 3 to 2, and added WEBSITE_DIR. --- gui/install.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/gui/install.sh b/gui/install.sh index bc7cd78b4..9cb7f133a 100755 --- a/gui/install.sh +++ b/gui/install.sh @@ -13,7 +13,7 @@ echo "*** Welcome to the Allsky Web User Interface (WebUI) installation ***" echo -e "*********************************************************************" echo -en '\n' -if [[ $EUID -ne 0 ]]; then +if [[ ${EUID} -ne 0 ]]; then echo -e "${RED}This script must be run as root${NC}" 1>&2 exit 1 fi @@ -29,13 +29,15 @@ modify_locations() echo -e "${GREEN}* Modifying locations in web files${NC}" ( cd "${PORTAL_DIR}/includes" || exit 1 - # NOTE: Only want to replace the FIRST instance of XX_ALLSKY_HOME_XX in funciton.php - # Otherwise, the edit check in functions.php will always fail. - sed -i "0,/XX_ALLSKY_HOME_XX/{s;XX_ALLSKY_HOME_XX;${ALLSKY_HOME};}" functions.php - sed -i "s;XX_ALLSKY_HOME_XX;${ALLSKY_HOME};" save_file.php - sed -i -e "s;XX_ALLSKY_SCRIPTS_XX;${ALLSKY_SCRIPTS};" \ + sed -i -e "s;XX_ALLSKY_HOME_XX;${ALLSKY_HOME};" \ + -e "s;XX_ALLSKY_WEBSITE_XX;${WEBSITE_DIR};" \ + save_file.php + + sed -i -e "s;XX_ALLSKY_HOME_XX;${ALLSKY_HOME};" \ + -e "s;XX_ALLSKY_SCRIPTS;${ALLSKY_SCRIPTS};" \ -e "s;XX_ALLSKY_IMAGES_XX;${ALLSKY_IMAGES};" \ -e "s;XX_ALLSKY_CONFIG_XX;${ALLSKY_CONFIG};" \ + -e "s;XX_ALLSKY_WEBSITE_XX;${WEBSITE_DIR};" \ -e "s;XX_RASPI_CONFIG_XX;${CONFIG_DIR};" \ functions.php ) @@ -119,14 +121,14 @@ echo echo -e "${GREEN}* Configuring lighttpd${NC}" # "/home/pi/allsky" is hard coded into file we distribute -sed -i "s|/home/pi/allsky|$(dirname "$SCRIPTPATH")|g" $SCRIPTPATH/lighttpd.conf -install -m 0644 $SCRIPTPATH/lighttpd.conf /etc/lighttpd/lighttpd.conf +sed -i "s|/home/pi/allsky|$(dirname "${SCRIPTPATH}")|g" "${SCRIPTPATH}/lighttpd.conf" +install -m 0644 "${SCRIPTPATH}/lighttpd.conf" /etc/lighttpd/lighttpd.conf echo if [ "${NEED_TO_UPDATE_HOST_NAME}" = "true" ]; then echo -e "${GREEN}* Changing hostname to '${HOST_NAME}'${NC}" - echo "$HOST_NAME" > /etc/hostname - sed -i "s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\t$HOST_NAME/g" /etc/hosts + echo "${HOST_NAME}" > /etc/hostname + sed -i "s/127.0.1.1.*${CURRENT_HOSTNAME}/127.0.1.1\t${HOST_NAME}/g" /etc/hosts echo else echo -e "${GREEN}* Leaving hostname at '${HOST_NAME}'${NC}" @@ -137,8 +139,8 @@ FILE="/etc/avahi/avahi-daemon.conf" if [ $? -ne 0 ]; then # New HOST_NAME not found, or file doesn't exist, so need to configure file. echo -e "${GREEN}* Configuring avahi-daemon${NC}" - install -m 0644 $SCRIPTPATH/avahi-daemon.conf "${FILE}" - sed -i "s/allsky/$HOST_NAME/g" "${FILE}" # "allsky" is hard coded in file we distribute + install -m 0644 "${SCRIPTPATH}/avahi-daemon.conf" "${FILE}" + sed -i "s/allsky/${HOST_NAME}/g" "${FILE}" # "allsky" is hard coded in file we distribute echo fi @@ -195,7 +197,7 @@ else install -m 0644 -o www-data -g www-data ${ALLSKY_CONFIG}/settings_RPiHQ.json "${CONFIG_DIR}" fi chown -R www-data:www-data "${CONFIG_DIR}" -usermod -a -G www-data $SUDO_USER +usermod -a -G www-data ${SUDO_USER} echo # don't leave unused files around rm -f ${ALLSKY_CONFIG}/settings_ZWO.json ${ALLSKY_CONFIG}/settings_RPiHQ.json @@ -204,7 +206,7 @@ echo -e "${GREEN}* Modify config.sh${NC}" sed -i "/CAMERA_SETTINGS_DIR=/c\CAMERA_SETTINGS_DIR=\"${CONFIG_DIR}\"" ${ALLSKY_CONFIG}/config.sh echo -en '\n' -if (whiptail --title "Allsky Software Installer" --yesno "The Allsky WebUI is now installed. You can now reboot the Raspberry Pi and connect to it at this address: http://$HOST_NAME.local or http://$(hostname -I | sed -e 's/ .*$//') Would you like to Reboot now?" 10 60 \ +if (whiptail --title "Allsky Software Installer" --yesno "The Allsky WebUI is now installed. You can now reboot the Raspberry Pi and connect to it at this address: http://${HOST_NAME}.local or http://$(hostname -I | sed -e 's/ .*$//') Would you like to Reboot now?" 10 60 \ 3>&1 1>&2 2>&3); then reboot now else From bcb3aadb37deea632c67446717fcafe22cb4aae1 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 6 May 2022 03:22:43 -0500 Subject: [PATCH 5/8] install.sh: update list of commands Since "ifconfig" is being added in the PR to "sudoers", check for it during installation. --- gui/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/install.sh b/gui/install.sh index 9cb7f133a..94bd344ca 100755 --- a/gui/install.sh +++ b/gui/install.sh @@ -87,8 +87,8 @@ if [ "${1}" = "--update" ] || [ "${1}" = "-update" ] ; then # Add entries to sudoers file if not already there. # This is only needed for people who updated allsky-portal but didn't update allsky. # Don't simply copy the "allsky" file to /etc/sudoers.d in case "allsky" isn't up to date. - grep --silent "/usr/bin/vcgencmd" /etc/sudoers.d/allsky && - grep --silent "postData.sh" /etc/sudoers.d/allsky + grep --silent "postData.sh" /etc/sudoers.d/allsky && + grep --silent "ifconfig" /etc/sudoers.d/allsky # shellcheck disable=SC2181 if [ $? -ne 0 ]; then echo -e "${GREEN}* Updating sudoers list${NC}" From d33e1e1bffb20a26647662d93401c062915f6b99 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 6 May 2022 03:48:01 -0500 Subject: [PATCH 6/8] variables.sh: change variable names To be consistent with all other variables pointing to directories, add ALLSKY_WEBUI and ALLSKY_WEBSITE. The old names will go away in a future release. --- variables.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/variables.sh b/variables.sh index dba644d23..723c67516 100644 --- a/variables.sh +++ b/variables.sh @@ -57,8 +57,10 @@ if [ "${ALLSKY_VARIABLE_SET}" = "" ]; then ALLSKY_DARKS="${ALLSKY_DARKS:-${ALLSKY_HOME}/darks}" # Location of optional allsky-portal package. - PORTAL_DIR=${PORTAL_DIR:-/var/www/html} + ALLSKY_WEBUI=${ALLSKY_WEBUI:-/var/www/html} + PORTAL_DIR=${ALLSKY_WEBUI} # old name - will eventually remove this # Location of optional allsky-website package. - WEBSITE_DIR=${WEBSITE_DIR:-${PORTAL_DIR}/allsky} + ALLSKY_WEBSITE=${ALLSKY_WEBSITE:-${ALLSKY_WEBUI}/allsky} + WEBSITE_DIR=${ALLSKY_WEBSITE} # old name - will eventually remove this fi From ee6eaf2be4e2119e1f4ee145c840955c1a8357b9 Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 6 May 2022 04:08:49 -0500 Subject: [PATCH 7/8] install.sh: replace placeholders in lighttpd.conf And add ALLSKY_WEBSITE which is needed by the WebUI. --- gui/install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gui/install.sh b/gui/install.sh index 94bd344ca..b8b53de37 100755 --- a/gui/install.sh +++ b/gui/install.sh @@ -120,8 +120,11 @@ service lighttpd restart echo echo -e "${GREEN}* Configuring lighttpd${NC}" -# "/home/pi/allsky" is hard coded into file we distribute -sed -i "s|/home/pi/allsky|$(dirname "${SCRIPTPATH}")|g" "${SCRIPTPATH}/lighttpd.conf" +sed -i \ + -e "s|XX_ALLSKY_HOME_XX|${ALLSKY_HOME}|g" \ + -e "s|XX_ALLSKY_IMAGES_XX|${ALLSKY_IMAGES}|g" \ + -e "s|XX_ALLSKY_WEBSITE_XX|${ALLSKY_WEBSITE}|g" \ + "${SCRIPTPATH}/lighttpd.conf" install -m 0644 "${SCRIPTPATH}/lighttpd.conf" /etc/lighttpd/lighttpd.conf echo From 8c958007ab88eddadbb22f0afd370dff3a938a8f Mon Sep 17 00:00:00 2001 From: EricClaeys <83164203+EricClaeys@users.noreply.github.com> Date: Fri, 6 May 2022 04:10:08 -0500 Subject: [PATCH 8/8] lighttpd.conf: Use placeholders * Add a placeholder for "website" which is needed by the WebUI. * To be consistent with other installation scripts, use placeholders that will be replaced during installation. --- gui/lighttpd.conf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gui/lighttpd.conf b/gui/lighttpd.conf index e336b81e6..021c391cd 100644 --- a/gui/lighttpd.conf +++ b/gui/lighttpd.conf @@ -26,8 +26,10 @@ $HTTP["url"] =~ "thumbnails|allsky/videos|allsky/startrails|allsky/keograms" { ) } -alias.url = ("/current/" => "/home/pi/allsky/") -alias.url += ("/images/" => "/home/pi/allsky/images/") +alias.url = ("/current/" => "XX_ALLSKY_HOME_XX") +alias.url += ("/images/" => "XX_ALLSKY_IMAGES_XX") +alias.url += ("/website/" => "XX_ALLSKY_WEBSITE_XX") + # strict parsing and normalization of URL for consistency and security # https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_http-parseoptsDetails # (might need to explicitly set "url-path-2f-decode" = "disable"