2024-05-05 06:16:56 +07:00
|
|
|
#!/usr/bin/env ash
|
|
|
|
#
|
|
|
|
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304>
|
|
|
|
#
|
|
|
|
# This is free software, licensed under the MIT License.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ "${1}" = "late" ]; then
|
|
|
|
echo "Installing addon revert - ${1}"
|
|
|
|
|
|
|
|
mkdir -p "/tmpRoot/usr/arc/"
|
|
|
|
echo '#!/usr/bin/env bash' >"/tmpRoot/usr/arc/revert.sh"
|
|
|
|
chmod +x "/tmpRoot/usr/arc/revert.sh"
|
|
|
|
|
|
|
|
mkdir -p "/tmpRoot/usr/arc/addons/"
|
|
|
|
for F in $(ls /tmpRoot/usr/arc/addons/* 2>/dev/null); do
|
|
|
|
if grep -q "/addons/${F##*/}" "/addons/addons.sh" 2>/dev/null; then continue; fi
|
|
|
|
chmod +x "${F}" || true
|
|
|
|
"${F}" "uninstall" || true
|
|
|
|
rm -f "${F}" || true
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! "$(cat "/tmpRoot/usr/arc/revert.sh")" = '#!/usr/bin/env bash' ]; then
|
|
|
|
mkdir -p "/tmpRoot/usr/lib/systemd/system"
|
|
|
|
DEST="/tmpRoot/usr/lib/systemd/system/revert.service"
|
2024-09-19 22:26:10 +07:00
|
|
|
cat <<EOF >${DEST}
|
|
|
|
[Unit]
|
|
|
|
Description=revert
|
|
|
|
After=multi-user.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
RemainAfterExit=yes
|
|
|
|
ExecStart=/usr/arc/revert.sh
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
2024-05-05 06:16:56 +07:00
|
|
|
|
|
|
|
mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
|
|
|
|
ln -vsf /usr/lib/systemd/system/revert.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/revert.service
|
|
|
|
else
|
|
|
|
rm -f "/tmpRoot/usr/lib/systemd/system/revert.service"
|
|
|
|
rm -f "/tmpRoot/usr/lib/systemd/system/multi-user.target.wants/revert.service"
|
|
|
|
fi
|
|
|
|
|
2024-06-08 21:20:47 +07:00
|
|
|
# backup current loader configs
|
2024-05-05 06:16:56 +07:00
|
|
|
rm -rf "/tmpRoot/usr/arc/backup"
|
|
|
|
if [ -d "/usr/arc/backup" ]; then
|
|
|
|
mkdir -p "/tmpRoot/usr/arc/backup"
|
|
|
|
cp -rf /usr/arc/backup/* "/tmpRoot/usr/arc/backup/"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Version
|
2024-06-08 21:20:47 +07:00
|
|
|
echo "LOADERLABEL=\"${LOADERLABEL}\"" >"/tmpRoot/usr/arc/VERSION"
|
|
|
|
echo "LOADERVERSION=\"${LOADERVERSION}\"" >>"/tmpRoot/usr/arc/VERSION"
|
2024-05-05 06:16:56 +07:00
|
|
|
|
|
|
|
fi
|