1
|
1 #!/bin/sh
|
|
2
|
|
3 usage () {
|
3
|
4 echo "usage: [DESTDIR=/] [PREFIX=/usr] $(basename "$0") install|uninstall|update" && exit 1
|
1
|
5 }
|
|
6
|
|
7 remove () {
|
|
8 [ -e "$1" ] && rm -vrf --preserve-root "$1"
|
|
9 }
|
|
10
|
|
11 install_dir () {
|
|
12 mkdir -p "$2"
|
|
13 cp -rv "$1" "$2"
|
|
14 }
|
|
15
|
|
16 [ $# -eq 1 ] && action=$1 || usage
|
|
17
|
|
18 [ -z "$DESTDIR" ] && DESTDIR=/
|
|
19 [ -z "$PREFIX" ] && PREFIX=/usr
|
|
20 _PREFIX=${DESTDIR%%/}/${PREFIX##/}
|
|
21
|
|
22 [ ! -w "$DESTDIR" ] && echo "You don't have write access on $DESTDIR" && exit 1
|
|
23
|
|
24 progname=feed-push
|
3
|
25 confdir="${DESTDIR}etc/$progname"
|
1
|
26
|
|
27 if [ "$action" == install ]; then
|
|
28 install -v -m 755 -D $progname "$_PREFIX/bin/$progname"
|
|
29 install_dir examples "$_PREFIX/share/$progname"
|
3
|
30 [ -d /etc/rc.d ] && install_dir rc.d "${DESTDIR}etc" && mkdir -v "$confdir"
|
1
|
31 elif [ "$action" == uninstall ]; then
|
3
|
32 remove "$_PREFIX/bin/$progname"
|
|
33 remove "$_PREFIX/share/$progname/examples"
|
|
34 remove "${DESTDIR}etc/rc.d/$progname"
|
|
35 if [ $(ls -a "$confdir") -eq 2 ]; then rmdir "$confdir"
|
|
36 else echo "not removing config dir $confdir (not empty)"
|
|
37 fi
|
|
38 elif [ "$action" == update ]; then
|
|
39 $0 uninstall &>/dev/null
|
|
40 $0 install
|
1
|
41 else
|
|
42 usage
|
|
43 fi
|
|
44
|
|
45 exit 0
|