forked from DebianDog/Squeeze
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next-save
51 lines (42 loc) · 1.22 KB
/
next-save
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
#!/bin/bash
# 20170801 saintless for Retro-Debian and DebianDog.
# Option to save on exit in multiple directories for frugal install on ext partition using aufs.
# GNU GPL v3 applies. No warranty of any kind.
if [ "$(whoami)" != "root" ]; then
echo "You have to run this script as Superuser."
exit
fi
BASE="/live/image/live-squeeze"
DIR="10.dir"
echo
echo "For frugal install on EXT partition only !!! "
echo "Save session in subfolders from 10.dir to 99.dir"
echo in "$BASE" loaded on next boot.
echo
read -p "Do you want to continue (y/n)?" choose
case "$choose" in
y|Y ) echo "Continue...";;
* ) exit;;
esac
#NEXT= line source: https://stackoverflow.com/questions/1587059/bash-find-highest-numbered-filename-in-a-directory-where-names-start-with-digit
NEXT=$(ls "$BASE" | grep ".dir" | sort -rn | awk '{FS="_"; printf "%0d.dir\n",$1+1;exit}')
if [ ! -d "$BASE" ]; then
echo No "$BASE" found. Change BASE= to your boot folder name.
exit
fi
if [ ! -d "$BASE"/"$DIR" ]; then
echo Saving session in "$BASE"/"$DIR" ...
mkdir "$BASE"/"$DIR"
cp -ap /live/cow/* "$BASE"/"$DIR"
sync
echo "Done."
exit
else
echo Saving session in "$BASE"/"$NEXT" ...
echo "$NEXT"
mkdir "$BASE"/"$NEXT"
cp -ap /live/cow/* "$BASE"/"$NEXT"
sync
echo "Done."
fi
exit