2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2023 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 logger
-t
"extrahd" "${message}"
29 local _mountpoint
="${1}"
37 while IFS
=';' read -r device filesystem mountpoint rest
; do
38 # Filter by mountpoint if set
39 if [ -n
"${_mountpoint}" ] && [ "${mountpoint}" != "${_mountpoint}" ]; then
43 # Check that the mountpoint starts with a slash
44 if [ "${mountpoint:0:1}" != "/" ]; then
45 log "Skipping invalid mountpoint: ${mountpoint}"
49 # Skip mounting if something is already mounted at the mountpoint
50 if mountpoint
"${mountpoint}" &>/dev/null
; then
54 # Ensure the mountpoint exists
55 mkdir --parents
--mode
=777 "${mountpoint}" &>/dev/null
57 if mount
--types
"${filesystem}" "${device}" "${mountpoint}"; then
58 log "Successfully mounted ${device} to ${mountpoint}"
60 log "Could not mount ${device} to ${mountpoint}: $?"
63 done
< /var/ipfire
/extrahd/devices
69 local _mountpoint
="${1}"
77 while IFS
=';' read -r device filesystem mountpoint rest
; do
78 # Filter by mountpoint if set
79 if [ -n
"${_mountpoint}" ] && [ "${mountpoint}" != "${_mountpoint}" ]; then
83 # Do not try to umount if nothing is mounted
84 if ! mountpoint
"${mountpoint}" &>/dev/null
; then
88 # Umount and try lazy umount if failed
89 if umount
--quiet
--recursive
"${mountpoint}" || \
90 umount
--quiet
--recursive
--lazy
"${mountpoint}"; then
91 log "Successfully umounted ${device} from ${mountpoint}"
93 log "Could not umount ${device} from ${mountpoint}: $?"
96 done
< /var/ipfire
/extrahd/devices
107 extrahd_mount
"${@}" || rc
="${?}"
110 extrahd_umount
"${@}" || rc
="${rc}"
113 exec /usr/local/bin/scanhd
"${@}"
118 echo
"${0}: No command given" >&2
124 echo
"${0}: Unsupported command: ${command}" >&2
133 main
"${@}" || exit ${?
}