forked from phorward/viur-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
updatedb.sh
executable file
·79 lines (63 loc) · 1003 Bytes
/
updatedb.sh
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
#!/bin/sh
TMPDIR=/tmp
DBDIR=$HOME/DB
cd $TMPDIR
if [ $? -ne 0 ]
then
echo "No /tmp directory??"
exit 1
fi
if [ ! -d $DBDIR ]
then
echo "No DB directory in $HOME found."
exit 1
fi
choice=0
dirlist=`ls -dt1 appengine.*.*/`
while true
do
cnt=0
sel=""
selname=""
echo "---"
for i in $dirlist
do
name=`echo $i | cut -f 2 -d '.'`
if [ $cnt -eq $choice ]
then
printf "> %2d %s\n" $cnt $name
sel=${i%/}
selname=$name
else
printf " %2d %s\n" $cnt $name
fi
cnt=`expr $cnt + 1`
done
if [ $cnt -eq 0 ]
then
echo "No Databases available."
exit 1
fi
printf "Select [%s]>" $selname
read nchoice
if [ -z "$nchoice" ]
then
echo -n "Saving '$sel' into $HOME/DB/$selname.tar.gz ..."
ln -s $sel storage
tar cfhz $DBDIR/$selname.tar.gz storage
rm storage
if [ $? -ne 0 ]
then
echo "Failed"
exit 1
fi
echo "Done"
break
fi
if [ $nchoice -ge $cnt -o $nchoice -lt 0 ]
then
echo "Invalid selection!"
continue
fi
choice=$nchoice
done