Files
bpfire/src/pakfire/lib/functions.sh
Peter Müller d0ba077ed3 Pakfire: call "sync" in function.sh after having extracted archives
After upgrading to Core Update 157, a few number of users reported their
systems to be unworkable after a reboot. Most of them (the systems, not
the users) were apparently missing the new Linux kernel in their Grub
configuration, causing a non-functional bootloader written to disk.

While we seem to be able to rule out issues related to poor storage
(SDDs, flash cards, etc.) or very high I/O load, it occurred to me we
are not calling "sync" after having extracted a Core Update's .tar.gz
file.

This patch therefore proposes to do so. It is a somewhat homeopathic
approach, though, but might ensure all parts of the system to have
properly processed the contents of an extracted archive. While we cannot
even reasonably guess it will solve the problem(s) mentioned initially,
doing so cannot hurt either.

See also:
https://community.ipfire.org/t/after-update-ipfire-to-157-no-boot/5641/45

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-07-09 13:54:39 +00:00

122 lines
3.3 KiB
Bash

#!/bin/bash
###############################################################################
# #
# IPFire.org - A linux based firewall #
# Copyright (C) 2007-2021 IPFire Team <info@ipfire.org> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
. /etc/sysconfig/rc
. $rc_functions
TAR_OPTIONS=(
--acls
--xattrs
--xattrs-include='*'
--no-overwrite-dir
--no-delay-directory-restore
--preserve-permissions
--numeric-owner
)
extract_files() {
echo "Extracting files..."
tar -xavf /opt/pakfire/tmp/files* "${TAR_OPTIONS[@]}" -C /
sync
echo "...Finished."
}
extract_backup_includes() {
echo "Extracting backup includes..."
tar xavf /opt/pakfire/tmp/files* "${TAR_OPTIONS[@]}" -C / \
var/ipfire/backup/addons/includes
sync
echo "...Finished."
}
remove_files() {
echo "Removing files..."
for i in $(cat /opt/pakfire/db/rootfiles/${NAME}); do
rm -rfv /${i}
done
echo "...Finished."
}
make_backup() {
if [ -e "/var/ipfire/backup/addons/includes/${1}" ]; then
echo "Creating Backup..."
/usr/local/bin/backupctrl addonbackup ${1}
echo "...Finished."
fi
}
restore_backup() {
if [ -e "/var/ipfire/backup/addons/backup/${1}.ipf" ]; then
echo "Restoring Backup..."
/usr/local/bin/backupctrl restoreaddon ${1}.ipf
echo "...Finished."
fi
}
restart_service() {
/etc/init.d/${1} restart
}
start_service() {
DELAY=0
while true
do
case "${1}" in
--delay|-d)
DELAY=${2}
shift 2
;;
--background|-b)
BACKGROUND="&"
shift
;;
-*)
log_failure_msg "Unknown Option: ${1}"
return 2 #invalid or excess argument(s)
;;
*)
break
;;
esac
done
if [ -f "/etc/init.d/${1}" ]; then
if [ -n "${BACKGROUND}" ]; then
(sleep ${DELAY} && /etc/init.d/${1} start) &
else
sleep ${DELAY} && /etc/init.d/${1} start
fi
fi
}
stop_service() {
if [ -f "/etc/init.d/${1}" ]; then
/etc/init.d/${1} stop
fi
}
rebuild_langcache() {
echo "Rebuilding language cache..."
perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
echo "...Finished."
}