Skip to content

Commit

Permalink
lets perform the storagePath setup in S62HMServer rather than
Browse files Browse the repository at this point in the history
S06InitSystem because that's actually the position where the storage
path is important to be setup and available correctly, which in fact
might not be the case in S06InitSystem. This refs #1377.
  • Loading branch information
jens-maus committed Aug 13, 2021
1 parent 3e89a15 commit a374ad0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
31 changes: 0 additions & 31 deletions buildroot-external/overlay/base/etc/init.d/S06InitSystem
Original file line number Diff line number Diff line change
Expand Up @@ -100,37 +100,6 @@ init_system() {
if echo "${HM_HOST}" | grep -q rpi; then
modprobe bcm2835_wdt nowayout=1 heartbeat=15
fi

# if the userfs is located on a non-mmc device (not on a SD card)
# we can safely use the old /usr/local/sdcard directory path as
# the general storagePath for diagrams and daily backups
storagePath=""
if [[ "${HM_HOST}" == "oci" ]] || grep " /usr/local " /proc/mounts | grep -qv "^/dev/mmc"; then
storagePath="/usr/local/sdcard"
mkdir -p ${storagePath}
fi

# users can override the storagePath by specifying an own storage
# path in /etc/config/CustomStoragePath
if [[ -f /etc/config/CustomStoragePath ]]; then
storagePath=$(cat /etc/config/CustomStoragePath)
fi

# in case a storagePath is specified we make sure it is setup
# correct and in case it is empty or does not exist we skip this
# so that the WebUI will remind users to insert an USB drive for
# storing diagrams+backups
if [[ -n "${storagePath}" ]] && [[ -d "${storagePath}" ]]; then
if [[ ! -d "${storagePath}/measurement" ]]; then
mkdir -p "${storagePath}/measurement"
fi
if [[ ! -e "${storagePath}/.nobackup" ]]; then
touch "${storagePath}/.nobackup"
fi
ln -sf "${storagePath}" /media/usb0
touch /var/status/SDinitialised
touch /var/status/hasSD
fi
}

start() {
Expand Down
31 changes: 31 additions & 0 deletions buildroot-external/overlay/base/etc/init.d/S62HMServer
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,37 @@ init() {
fi
fi

# if the userfs is located on a non-mmc device (not on a SD card)
# we can safely use the old /usr/local/sdcard directory path as
# the general storagePath for diagrams and daily backups
storagePath=""
if [[ "${HM_HOST}" == "oci" ]] || grep " /usr/local " /proc/mounts | grep -qv "^/dev/mmc"; then
storagePath="/usr/local/sdcard"
mkdir -p ${storagePath}
fi

# users can override the storagePath by specifying an own storage
# path in /etc/config/CustomStoragePath
if [[ -f /etc/config/CustomStoragePath ]]; then
storagePath=$(cat /etc/config/CustomStoragePath)
fi

# in case a storagePath is specified we make sure it is setup
# correct and in case it is empty or does not exist we skip this
# so that the WebUI will remind users to insert an USB drive for
# storing diagrams+backups
if [[ -n "${storagePath}" ]] && [[ -d "${storagePath}" ]]; then
if [[ ! -d "${storagePath}/measurement" ]]; then
mkdir -p "${storagePath}/measurement"
fi
if [[ ! -e "${storagePath}/.nobackup" ]]; then
touch "${storagePath}/.nobackup"
fi
ln -sf "${storagePath}" /media/usb0
touch /var/status/SDinitialised
touch /var/status/hasSD
fi

# lets build HMServer.conf with own diagram path
sed "s|^diagramDatabasePath=.*$|diagramDatabasePath=/tmp/measurement|" /etc/HMServer.conf >/var/etc/HMServer.conf

Expand Down

0 comments on commit a374ad0

Please sign in to comment.