updated on Wed Jan 25 16:08:47 UTC 2012
[aur-mirror.git] / curveprotect / curveprotect.install
blob7eedbc4b89be76a8a18e389aea45f2e0bc1e98a3
1 ## arg 1:  the new package version
2 pre_install() {
3   # do something here
4   exit 0
7 ## arg 1:  the new package version
8 post_install() {
9   curveprotectbase=/opt/curveprotect
10   grp=cpgrp
11   log=cplog
12   usr=cpusr
13   cfg=cpcfg
14   dwr=cpdwr
15   dwl=cpdwl
17   if ! grep -q "^${grp}:" /etc/group; then
18     groupadd --system "${grp}"
19   fi
21   for x in "${log}" "${usr}" "${cfg}"; do
22     if ! grep -q "^${x}:" /etc/passwd; then
23       useradd --system --home /nonexistent -g "${grp}" -c "Curveprotect ${x} user" "${x}"
24     fi
25   done
27   for x in "${dwr}" "${dwl}"; do
28     if ! grep -q "^${x}:" /etc/passwd; then
29       useradd --system --shell /bin/sh --create-home --home "/opt/curveprotect/home/${x}" -g "${grp}" -c "Curveprotect user for downloading zones" "${x}"
30     fi
31   done
34   #get key
35   su -c 'gpg --import /opt/curveprotect/share/gnupgkey-20E3C425-valid-to-20130206.pub' "${dwr}" || :
36   echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "
37   echo "!!!!! check please fingerprint !!! "
38   echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "
40   #XXX
41   if [ ! -e /service ]; then
42     if [ -e /etc/service ]; then
43       ln -s /etc/service /service
44     fi
45   fi
48   #X
49   (
50     cd /opt/curveprotect/service
51     ls -1  |\
52     while read d
53     do
54         (
55           cd "${d}"
56           envuidgid "${cfg}" /opt/curveprotect/bin/trycreatesupervise
57         )
58         ldir="/opt/curveprotect/log/${d}"
59         [ -d "${ldir}" ] || mkdir "${ldir}"
60         chown "${log}" "${ldir}"
61         chgrp "${grp}" "${ldir}"
62         chmod 750 "${ldir}"
63         [ -h "/service/curveprotect_${d}" ] || ln -s "/opt/curveprotect/service/${d}" "/service/curveprotect_${d}"
64     done
65   )
67   # perms
68   chown "${log}" /opt/curveprotect/log
69   chgrp "${grp}" /opt/curveprotect/log
70   chown -R "${dwl}" /opt/curveprotect/var/dnslocal
71   chown -R "${dwr}" /opt/curveprotect/var/dnsroot
72   chown "${usr}" /opt/curveprotect/etc/dnscache/root/dump
73   chgrp "${grp}" /opt/curveprotect/etc/dnscache/root/dump
74   mkdir -p ${curveprotectbase}/.keys || :
75   chown -R "${usr}" /opt/curveprotect/.keys
76   chgrp -R "${grp}" /opt/curveprotect/.keys
78   # cfg perms
79   find /opt/curveprotect/etc -type d -name 'env' -exec chown -R "${cfg}" '{}' ';'
80   find /opt/curveprotect/etc/vpn* -type d -name 'root' -exec chown -R "${cfg}" '{}' ';'
81   chown -R "${cfg}" /opt/curveprotect/etc/dnscache/root/servers
82   chown -R "${cfg}" /opt/curveprotect/etc/dnslocal/root
83   chown -R "${cfg}" /opt/curveprotect/etc/dnsroot/root
84   chown -R "${cfg}" /opt/curveprotect/etc/tmp
85   #X
90 ## arg 1:  the new package version
91 ## arg 2:  the old package version
92 pre_upgrade() {
93   # do something here
94   exit 0
97 ## arg 1:  the new package version
98 ## arg 2:  the old package version
99 post_upgrade() {
100   grp=cpgrp
101   log=cplog
102   usr=cpusr
103   cfg=cpcfg
104   dwr=cpdwr
105   dwl=cpdwl
107   chown -R "${cfg}" /opt/curveprotect/etc/tmp
108   find /opt/curveprotect/etc/vpn* -type d -name 'root' -exec chown -R "${cfg}" '{}' ';'
110   for i in `ls /opt/curveprotect/service 2>/dev/null`; do
111       cd "/service/curveprotect_${i}"
112       svc -k . log
113       echo "restarting: /service/curveprotect_${i}"
114   done
118 ## arg 1:  the old package version
119 pre_remove() {
120   #stop services
121   for i in `ls /opt/curveprotect/service 2>/dev/null`; do
122       cd "/service/curveprotect_${i}"
123       rm "/service/curveprotect_${i}"
124       svc -dx . log
125       echo "stopping: /service/curveprotect_${i}"
126   done
129 ## arg 1:  the old package version
130 post_remove() {
131   grp=cpgrp
132   log=cplog
133   usr=cpusr
134   dwr=cpdwr
135   dwl=cpdwl
136   cfg=cpcfg
138   rm -rf /var/log/curveprotect
139   rm -rf /etc/curveprotect
140   userdel -f "${usr}" || :
141   userdel -f "${log}" || :
142   userdel -f "${dwr}" || :
143   userdel -f "${dwl}" || :
144   userdel -f "${cfg}" || :
145   groupdel "${grp}" || :
146   ( 
147     cd /opt/curveprotect
148     rm -rf home html lib log service tmp var www etc
149   )