Create buildtimestamp.txt if not exists, fix shellcheck warnings

This commit is contained in:
Markus Lorenz
2023-11-15 14:09:52 +01:00
parent a0d34876cc
commit 1e75eeab4c
4 changed files with 20 additions and 16 deletions

View File

@@ -20,15 +20,15 @@ echo "---------------------------------------------------------"
# ----------------------------------------------------------------------
echo Updating... /usr/share/ieee-data/
cd /usr/share/ieee-data/
cd /usr/share/ieee-data/ || { echo "could not enter /usr/share/ieee-data directory"; exit 1; }
sudo mkdir -p 2_backup
sudo cp *.txt 2_backup
sudo cp *.csv 2_backup
sudo cp -- *.txt 2_backup
sudo cp -- *.csv 2_backup
echo ""
echo Download Start
echo ""
sudo curl $1 -LO https://standards-oui.ieee.org/iab/iab.csv \
sudo curl "$1" -LO https://standards-oui.ieee.org/iab/iab.csv \
-LO https://standards-oui.ieee.org/iab/iab.txt \
-LO https://standards-oui.ieee.org/oui28/mam.csv \
-LO https://standards-oui.ieee.org/iab/iab.txt \
@@ -44,10 +44,10 @@ echo Download Finished
# ----------------------------------------------------------------------
echo ""
echo Updating... /usr/share/arp-scan/
cd /usr/share/arp-scan
cd /usr/share/arp-scan || { echo "could not enter /usr/share/arp-scan directory"; exit 1; }
sudo mkdir -p 2_backup
sudo cp *.txt 2_backup
sudo cp -- *.txt 2_backup
# Update from /usb/lib/ieee-data
sudo get-iab -v

View File

@@ -31,7 +31,7 @@ echo "[INSTALL] Run setup scripts"
# Change port number if set
if [ -n "${PORT}" ]; then
sed -ie 's/listen 20211/listen '${PORT}'/g' /etc/nginx/sites-available/default
sed -ie 's/listen 20211/listen '"${PORT}"'/g' /etc/nginx/sites-available/default
fi
echo "[INSTALL] Setup NGINX"
@@ -60,7 +60,7 @@ fi
# Change web interface address if set
if [ -n "${LISTEN_ADDR}" ]; then
sed -ie 's/listen /listen '${LISTEN_ADDR}:'/g' /etc/nginx/conf.d/pialert.conf
sed -ie 's/listen /listen '"${LISTEN_ADDR}":'/g' /etc/nginx/conf.d/pialert.conf
fi
# Run the hardware vendors update at least once

View File

@@ -9,7 +9,7 @@ if [ -z "${USER}" ]; then
fi
# if both not set we do not need to do anything
if [ -z "${HOST_USER_ID}" -a -z "${HOST_USER_GID}" ]; then
if [ -z "${HOST_USER_ID}" ] && [ -z "${HOST_USER_GID}" ]; then
echo "Nothing to do here." ; exit 0
fi
@@ -20,20 +20,20 @@ USER_GID=${HOST_USER_GID:=$USER_GID}
LINE=$(grep -F "${USER}" /etc/passwd)
# replace all ':' with a space and create array
array=( ${LINE//:/ } )
array=( "${LINE//:/ }" )
# home is 5th element
USER_HOME=${array[4]}
# print debug output
echo USER_ID : ${USER_ID};
echo USER_GID : ${USER_GID};
echo USER_HOME: ${USER_HOME};
echo TZ : ${TZ};
echo USER_ID" ": "${USER_ID}";
echo USER_GID : "${USER_GID}";
echo USER_HOME: "${USER_HOME}";
echo TZ" ": "${TZ}";
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:[0-9]*/${USER}:\1:${USER_ID}:${USER_GID}/" /etc/passwd
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group
chown -R ${USER_ID}:${USER_GID} ${USER_HOME}
chown -R "${USER_ID}:${USER_GID} ${USER_HOME}"
exec su - "${USER}"
exec su - "${USER}"

View File

@@ -26,6 +26,10 @@ rm -R $INSTALL_DIR/pialert
# Clone the application repository
git clone https://github.com/jokob-sk/Pi.Alert "$INSTALL_DIR/pialert"
# Check for buildtimestamp.txt existence, otherwise create it
if [ ! -f /home/pi/pialert/front/buildtimestamp.txt ]; then
date +%s > /home/pi/pialert/front/buildtimestamp.txt
fi
# Start PiAlert
"$INSTALL_DIR/pialert/dockerfiles/start.sh"