blob: ff1ff0a1574d0615a6689a41e37d4fe9fb284fb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/bin/sh
PREFIX=
. "$PREFIX/lib/libalpine.sh"
usage() {
cat <<__EOF__
usage: setup-apklbu [-hi] [-m relative mountpoint]
Setup apk caching and lbu settings.
options:
-h Show this help
-i Run in installer mode (usually only when called by setup-alpine)
-m Specify mountpoint under /media for lbu backups (default is usb)
__EOF__
exit 1
}
while getopts "im:h" opt; do
case $opt in
i) VERBOSE="1";;
h) usage;;
m) MOUNTPOINT="$OPTARG";;
esac
done
if [ "$VERBOSE" = "1" ]; then
echo "Setup apk caching and lbu? (y/N)"
default_read setupapklbu
if [ "$setupapklbu" = "N" ] || [ "$setupapklbu" = "n" ]; then
exit 0
fi
if [ -z $MOUNTPOINT ]; then
MOUNTPOINT="usb"
echo "Please enter mountpoint directory under /media for lbu [$MOUNTPOINT]:"
default_read MOUNTPOINT "$MOUNTPOINT"
fi
fi
if [ -z $MOUNTPOINT ]; then
MOUNTPOINT="usb"
fi
mountstatus="`mount | grep /media/${MOUNTPOINT}`"
if [ -z $mountstatus ]; then
echo "$MOUNTPOINT is not mounted" && exit 1
fi
readwritestatus="`echo $mountstatus | awk -F '(' '{print $2}' | awk -F ',' '{print $1}'`"
if [ "$readwritestatus" = "ro" ]; then
rewrite=1
fi
if [ "$rewrite" = 1 ]; then
mount -o remount,rw /media/${MOUNTPOINT} || die "Failed to remount media rw"
fi
mkdir -p /media/${MOUNTPOINT}/cache || die "Failed to create /media/${MOUNTPOINT}/cache"
ln -s /media/${MOUNTPOINT}/cache /etc/apk/cache || die "Failed to create apk cache softlink"
apk cache sync
cat > /etc/lbu/lbu.conf <<EOF
# what cipher to use with -e option
DEFAULT_CIPHER=aes-256-cbc
# Uncomment the row below to encrypt config by default
# ENCRYPTION=$DEFAULT_CIPHER
# Uncomment below to avoid <media> option to 'lbu commit'
# Can also be set to 'floppy'
LBU_MEDIA=$MOUNTPOINT
# Uncomment below to let lbu make up to 3 backups
# BACKUP_LIMIT=3
EOF
lbu package /media/"$MOUNTPOINT" || die "Failed to lbu apkovl on /media/${MOUNTPOINT}"
sync
if [ "$rewrite" = 1 ]; then
mount -o remount,ro /media/${MOUNTPOINT} || die "Failed to remount media ro"
fi
|