-
Notifications
You must be signed in to change notification settings - Fork 0
/
update
executable file
·51 lines (41 loc) · 1.06 KB
/
update
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/sh
F=$(readlink -f "$0")
cd "$(dirname "$F")"
mkdir -p installed
# bold+cyan+on_orange
highlight=$(tput setab 3)$(tput bold)$(tput setaf 4)
normal=$(tput sgr0)
if [ $# -eq 0 ]; then
echo 'specify "all" or specific package to update:'
echo
echo installed packages:
ls installed | sed "s/^/+ /"
exit 1
fi
if [ ! -w . ]; then
echo Error: Write Permission Denied
echo Option 1: run from root: $highlight sudo $0 $* $normal
echo Option 2: change file ownership: $highlight sudo chown -R $USER $(dirname "$F") $normal, then run update command again
exit 1
fi
what=$1
if [ "$1" == "all" ]; then
for file in installed/*
do
what=$(echo $file | sed "s/^installed.//" )
./update $what
done
exit
fi
if [ ! -f scripts/$what.install ]; then
echo "unknown package '$what'"
exit 1
fi
if [ -f scripts/$what.update ]; then
echo "*** updating $highlight $what $normal"
sh -x scripts/$what.update
else
echo "*** re-installing $highlight $what $normal"
sh -x scripts/$what.install
fi
date > installed/$what