annotate setup @ 2:292896092ee6 draft

chmod +x rc.d/feed-push Signed-off-by: Changaco <changaco ατ changaco δοτ net>
author Changaco <changaco ατ changaco δοτ net>
date Mon, 16 Apr 2012 00:09:37 +0200
parents a68d7feeba88
children 0d4378996672
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
1 #!/bin/sh
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
2
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
3 usage () {
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
4 echo "usage: [DESTDIR=/] [PREFIX=/usr] $(basename "$0") install|uninstall" && exit 1
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
5 }
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
6
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
7 remove () {
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
8 [ -e "$1" ] && rm -vrf --preserve-root "$1"
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
9 }
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
10
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
11 install_dir () {
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
12 mkdir -p "$2"
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
13 cp -rv "$1" "$2"
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
14 }
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
15
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
16 [ $# -eq 1 ] && action=$1 || usage
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
17
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
18 [ -z "$DESTDIR" ] && DESTDIR=/
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
19 [ -z "$PREFIX" ] && PREFIX=/usr
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
20 _PREFIX=${DESTDIR%%/}/${PREFIX##/}
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
21
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
22 [ ! -w "$DESTDIR" ] && echo "You don't have write access on $DESTDIR" && exit 1
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
23
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
24 progname=feed-push
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
25
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
26 if [ "$action" == install ]; then
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
27 install -v -m 755 -D $progname "$_PREFIX/bin/$progname"
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
28 install_dir examples "$_PREFIX/share/$progname"
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
29 [ -d /etc/rc.d ] && install_dir rc.d "${DESTDIR}etc"
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
30 elif [ "$action" == uninstall ]; then
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
31 remove "$PREFIX/bin/$progname"
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
32 remove "$PREFIX/share/$progname/examples"
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
33 remove "/etc/rc.d/$progname"
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
34 else
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
35 usage
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
36 fi
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
37
a68d7feeba88 initial commit
Changaco <changaco ατ changaco δοτ net>
parents:
diff changeset
38 exit 0