projects/aports·blob master · refs

36 lines · 1.7 KiB

1#!/bin/sh
2
3SNAPPER_CONFIGS_FILE="/etc/snapper/snapper"
4SNAPPER_CONFIG_APK_SNAP_ITEM="root-apk-snap"
5
6# Check if /etc/snapper/snapper exists, add call to config for apk-snap
7if [ -f "$SNAPPER_CONFIGS_FILE" ]; then
8 # Extract the value of SNAPPER_CONFIGS from the file
9 SNAPPER_CONFIGS=$(awk -F'[:"]+' '/^SNAPPER_CONFIGS=/ {print $3}' "$SNAPPER_CONFIGS_FILE")
10
11 # Check if "root-apk-snap" is in the SNAPPER_CONFIGS
12 if [ -n "$SNAPPER_CONFIGS" ] && echo "$SNAPPER_CONFIGS" | grep -qw "$SNAPPER_CONFIG_APK_SNAP_ITEM"; then
13 SNAPPER_CONFIGS=$(echo "$SNAPPER_CONFIGS" | sed "s/\b$DEFAULT_SNAPPER_ITEM\b//g" | sed 's/ / /g' | sed 's/^ //;s/ $//')
14 sed -i "/^SNAPPER_CONFIGS=/s/=.*/=\"$SNAPPER_CONFIGS\"/" "$SNAPPER_CONFIGS_FILE"
15 echo "$SNAPPER_CONFIG_APK_SNAP_ITEM removed from SNAPPER_CONFIGS: $SNAPPER_CONFIGS"
16 fi
17else
18 echo "Snapper not properly installed, $SNAPPER_CONFIGS_FILE does not exist"
19fi
20
21
22# Check if snapper config for apk-snap, and snapshots subvol exists; and take appropriate action
23if [ -f "/etc/snapper/configs/root-apk-snap" ] && [ -d "/.snapshots" ]; then
24 echo "snapper config for apk-snap removed, ./snapshots subvol not removed."
25 rm -f /etc/snapper/configs/root-apk-snap
26
27elif [ -f "/etc/snapper/configs/root-apk-snap" ] && [ ! -d "/.snapshots" ]; then
28 echo "snapper config for apk-snap removed, snapshots subvol does not exist."
29 rm -f /etc/snapper/configs/root-apk-snap
30
31elif [ -f "/etc/snapper/configs/root-apk-snap" ] || [ -d "/.snapshots" ]; then
32 echo "snapper config for apk-snap does not exist, snapshots subvol not removed."
33
34elif [ -f "/etc/snapper/configs/root-apk-snap" ] || [ ! -d "/.snapshots" ]; then
35 echo "snapper config for apk-snap does not exist, snapshots subvol does not exist."
36fi