Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui-install.sh bug fix #591

Merged
merged 2 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions gui/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash

source ../config/variables.sh
if [ -z "${ALLSKY_HOME}" ] ; then
export ALLSKY_HOME=$(realpath $(dirname "${BASH_ARGV0}")/..)
fi
source ${ALLSKY_HOME}/variables.sh
PORTAL_DIR=${PORTAL_DIR:-/var/www/html}

if [ $# -eq 1 ] ; then
HOST_NAME=$1
Expand All @@ -15,7 +19,7 @@ echo "*** Welcome to the Allsky Administration Portal installation ***"
echo -e "****************************************************************"
echo -en '\n'
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
echo "${RED}This script must be run as root${NC}" 1>&2
exit 1
fi
echo -e "${GREEN}* Installation of the webserver${NC}"
Expand All @@ -30,37 +34,43 @@ echo -e "${GREEN}* Configuring lighttpd${NC}"
sed -i "s|/home/pi/allsky|$(dirname "$SCRIPTPATH")|g" $SCRIPTPATH/lighttpd.conf
install -m 0644 $SCRIPTPATH/lighttpd.conf /etc/lighttpd/lighttpd.conf
echo -en '\n'

echo -e "${GREEN}* Changing hostname to allsky${NC}"
echo "$HOST_NAME" > /etc/hostname
sed -i "s/raspberrypi/$HOST_NAME/g" /etc/hosts
echo -en '\n'

echo -e "${GREEN}* Setting avahi-daemon configuration${NC}"
install -m 0644 $SCRIPTPATH/avahi-daemon.conf /etc/avahi/avahi-daemon.conf
sed -i "s/allsky/$HOST_NAME/g" /etc/avahi/avahi-daemon.conf
echo -en '\n'

echo -e "${GREEN}* Adding the right permissions to the web server${NC}"
sed -i '/allsky/d' /etc/sudoers
sed -i '/www-data/d' /etc/sudoers
rm -f /etc/sudoers.d/allsky
cat $SCRIPTPATH/sudoers >> /etc/sudoers.d/allsky
echo -en '\n'

echo -e "${GREEN}* Retrieving github files to build admin portal${NC}"
rm -rf /var/www/html
git clone https://github.com/thomasjacquin/allsky-portal.git /var/www/html
chown -R ${SUDO_USER}:www-data /var/www/html
chmod -R 775 /var/www/html
rm -rf "${PORTAL_DIR}"
git clone https://github.com/thomasjacquin/allsky-portal.git "${PORTAL_DIR}"
chown -R ${SUDO_USER}:www-data "${PORTAL_DIR}"
chmod -R 775 "${PORTAL_DIR}"
mkdir -p /etc/raspap
mv /var/www/html/raspap.php /etc/raspap/
mv /var/www/html/camera_options_ZWO.json /etc/raspap/
mv /var/www/html/camera_options_RPiHQ.json /etc/raspap/
mv "${PORTAL_DIR}"/raspap.php /etc/raspap/
mv "${PORTAL_DIR}"/camera_options_ZWO.json /etc/raspap/
mv"${PORTAL_DIR}"/camera_options_RPiHQ.json /etc/raspap/
install -m 0644 -o www-data -g www-data ${ALLSKY_CONFIG}/settings_ZWO.json /etc/raspap/
install -m 0644 -o www-data -g www-data ${ALLSKY_CONFIG}/settings_RPiHQ.json /etc/raspap/
chown -R www-data:www-data /etc/raspap
usermod -a -G www-data $SUDO_USER
echo -en '\n'

echo -e "${GREEN}* Modify config.sh${NC}"
sed -i '/CAMERA_SETTINGS_DIR=/c\CAMERA_SETTINGS_DIR="/etc/raspap"' $ALLSKY_CONFIG/config.sh
echo -en '\n'

echo -en '\n'
echo "The Allsky Portal is now installed"
echo "You can now reboot the Raspberry Pi and connect to it from your laptop, computer, phone, tablet at this address: http://$HOST_NAME.local or http://`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`"
Expand Down
8 changes: 6 additions & 2 deletions variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ if [ "${ALLSKY_VARIABLE_SET}" = "" ]; then
ALLSKY_TMP="${ALLSKY_TMP:-${ALLSKY_HOME}/tmp}"

# Central location for all AllSky configuration files.
# xxxxxx NEW NAME xxxxxx
ALLSKY_CONFIG="${ALLSKY_CONFIG:-${ALLSKY_HOME}/config}"
# ALLSKY_CONFIG="${ALLSKY_HOME}" # xxx old location

# Holds all the scripts.
ALLSKY_SCRIPTS="${ALLSKY_SCRIPTS:-${ALLSKY_HOME}/scripts}"
Expand All @@ -53,4 +51,10 @@ if [ "${ALLSKY_VARIABLE_SET}" = "" ]; then

# Holds all the dark frames.
ALLSKY_DARKS="${ALLSKY_DARKS:-${ALLSKY_HOME}/darks}"

# Location of optional allsky-portal package.
PORTAL_DIR=${PORTAL_DIR:-/var/www/html}

# Location of optional allsky-website package.
WEBSITE_DIR=${WEBSITE_DIR:-${PORTAL_DIR}/allsky}
fi