source: Slackware/i2p-base/doinst.sh @ 5190b2d

Last change on this file since 5190b2d was 5190b2d, checked in by sponge <sponge@…>, 11 years ago

Fixups to Slackware scripts

  • Property mode set to 100644
File size: 5.6 KB
Line 
1#!/bin/sh
2#
3#
4# Now in the future we only need to look for '#I2P' and '#/I2P'
5# for modifications to rc.local and rc.local_shutdown.
6# I was a moron for not doing it this way in the first place :-) -- Sponge
7#
8#
9
10touch /etc/rc.d/rc.local
11touch /etc/rc.d/rc.local_shutdown
12
13echo
14echo -n "Check 1: /etc/rc.d/rc.local "
15I2PRCA=`grep -c /etc/rc.d/rc.local -e '/etc/rc.d/rc.i2p'`
16
17if [ $I2PRCA -eq 0 ] ; then
18        echo '#I2P' >> /etc/rc.d/rc.local
19        echo '( cd /tmp ; rm -Rf i2p-*.tmp )' >> /etc/rc.d/rc.local
20        echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local
21        echo "        sh /etc/rc.d/rc.i2p start" >> /etc/rc.d/rc.local
22        echo "fi" >> /etc/rc.d/rc.local
23        echo '#/I2P' >> /etc/rc.d/rc.local
24        echo "modified."
25else
26        echo -n "looks OK so far,"
27        # Fix old installs, or where people have modified.
28
29        echo -n " Check 1A: "
30        I2PRCC=`grep -c /etc/rc.d/rc.local -e 'i2p-\*\.tmp'`
31
32        if [ $I2PRCC -eq 0 ] ; then
33                DATA=$(cat /etc/rc.d/rc.local | sed -re 's/if \[ -x \/etc\/rc\.d\/rc\.i2p \] ; then/#I2P\n\( cd \/tmp ; rm -Rf i2p-*.tmp \)\nif \[ -x \/etc\/rc.d\/rc.i2p \] ; then/')
34                echo "${DATA}" > /etc/rc.d/rc.local
35                echo -n "additional modifications applied,"
36        else
37                echo -n "looks OK so far,"
38        fi
39
40        echo -n " Check 1B: "
41        I2PRCE=`grep -c /etc/rc.d/rc.local -e 'i2p-\*\.tmp'`
42        if [ $I2PRCE -eq 0 ] ; then
43                DATATOP=$(cat /etc/rc.d/rc.local | sed -n '0,/i2p-\*\.tmp/p' | sed '$d' )
44                DATABOT=$(cat /etc/rc.d/rc.local | sed -n '/i2p-\*\.tmp/,$p' | sed -n '/^fi/,$p' | sed "1d")
45                echo "${DATATOP}" > /etc/rc.d/rc.local
46                echo '#I2P' >> /etc/rc.d/rc.local
47                echo '( cd /tmp ; rm -Rf i2p-*.tmp )' >> /etc/rc.d/rc.local
48                echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local
49                echo "        sh /etc/rc.d/rc.i2p start" >> /etc/rc.d/rc.local
50                echo "fi" >> /etc/rc.d/rc.local
51                echo '#/I2P' >> /etc/rc.d/rc.local
52                echo "${DATABOT}" >> /etc/rc.d/rc.local
53               
54                echo -n "additional modifications applied,"
55        else
56                echo -n "looks ok so far,"
57        fi
58        echo -n " Check 1C: "
59        I2PRCF=`grep -c /etc/rc.d/rc.local -e '#/I2P'`
60        if [ $I2PRCF -eq 0 ] ; then
61                DATATOP=$(cat /etc/rc.d/rc.local | sed -n '0,/^#I2P/p' | sed '$d' )
62                DATABOT=$(cat /etc/rc.d/rc.local | sed -n '/^#I2P/,$p' | sed -n '/^fi/,$p' | sed "1d")
63                echo "${DATATOP}" > /etc/rc.d/rc.local
64                echo '#I2P' >> /etc/rc.d/rc.local
65                echo '( cd /tmp ; rm -Rf i2p-*.tmp )' >> /etc/rc.d/rc.local
66                echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local
67                echo "        sh /etc/rc.d/rc.i2p start" >> /etc/rc.d/rc.local
68                echo "fi" >> /etc/rc.d/rc.local
69                echo '#/I2P' >> /etc/rc.d/rc.local
70                echo "${DATABOT}" >> /etc/rc.d/rc.local
71
72                echo -n "additional modifications applied,"
73        else
74                echo -n "looks ok so far,"
75        fi
76        echo " Done."
77fi
78
79echo -n "Check 2: /etc/rc.d/rc.local_shutdown "
80I2PRCB=`grep -c /etc/rc.d/rc.local_shutdown -e '/etc/rc.d/rc.i2p'`
81if [ $I2PRCB -eq 0 ] ; then
82        echo "#I2P" >> /etc/rc.d/rc.local_shutdown
83        echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local_shutdown
84        echo "        sh /etc/rc.d/rc.i2p stop" >> /etc/rc.d/rc.local_shutdown
85        echo "fi" >> /etc/rc.d/rc.local_shutdown
86        echo "#/I2P" >> /etc/rc.d/rc.local_shutdown
87        echo "modified."
88else
89        echo -n "looks OK so far,"
90        # Fix old installs
91
92        echo -n " Check 1A: "
93        I2PRCG=`grep -c /etc/rc.d/rc.local_shutdown -e '#I2P'`
94        if [ $I2PRCG -eq 0 ] ; then
95                DATATOP=$(cat /etc/rc.d/rc.local_shutdown | sed -n '0,/^if \[ -x \/etc\/rc\.d\/rc\.i2p \] ; then/p' | sed '$d' )
96                DATABOT=$(cat /etc/rc.d/rc.local_shutdown | sed -n '/^if \[ -x \/etc\/rc\.d\/rc\.i2p \] ; then/,$p' | sed -n '/^fi/,$p' | sed "1d")
97                echo "${DATATOP}" > /etc/rc.d/rc.local_shutdown
98                echo '#I2P' >> /etc/rc.d/rc.local_shutdown
99                echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local_shutdown
100                echo "        sh /etc/rc.d/rc.i2p stop" >> /etc/rc.d/rc.local_shutdown
101                echo "fi" >> /etc/rc.d/rc.local_shutdown
102                echo "#/I2P" >> /etc/rc.d/rc.local_shutdown
103                echo "${DATABOT}" >> /etc/rc.d/rc.local_shutdown
104                echo -n "additional modifications applied,"
105        else
106                echo -n "looks OK so far,"
107        fi
108        echo -n " Check 1B: "
109        I2PRCH=`grep -c /etc/rc.d/rc.local_shutdown -e '#/I2P'`
110        if [ $I2PRCH -eq 0 ] ; then
111                DATATOP=$(cat /etc/rc.d/rc.local_shutdown | sed -n '0,/^#I2P/p' | sed '$d' )
112                DATABOT=$(cat /etc/rc.d/rc.local_shutdown | sed -n '/^#I2P/,$p' | sed -n '/^fi/,$p' | sed "1d")
113                echo "${DATATOP}" > /etc/rc.d/rc.local_shutdown
114                echo '#I2P' >> /etc/rc.d/rc.local_shutdown
115                echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local_shutdown
116                echo "        sh /etc/rc.d/rc.i2p stop" >> /etc/rc.d/rc.local_shutdown
117                echo "fi" >> /etc/rc.d/rc.local_shutdown
118                echo "#/I2P" >> /etc/rc.d/rc.local_shutdown
119                echo "${DATABOT}" >> /etc/rc.d/rc.local_shutdown
120                echo -n "additional modifications applied,"
121        else
122                echo -n "looks OK so far,"
123        fi
124        echo " Done."
125fi
126
127if [ -f /etc/rc.d/rc.i2p ] ; then
128        if [ -x /etc/rc.d/rc.i2p ] ; then
129                chmod +x /etc/rc.d/rc.i2p.new
130        fi
131        # Hopefully get admin's attention.
132        echo -ne "\007" ; sleep 0.3
133        echo -ne "\007" ; sleep 0.3
134        echo -ne "\007" ; sleep 0.3
135        echo -ne "\007" ; sleep 0.3
136        echo -ne "\007" ; sleep 0.3
137        echo -ne "\007" ; sleep 0.3
138        echo -e "\007" ; sleep 0.3
139        echo "It apears that you already have /etc/rc.d/rc.i2p"
140        echo "You should replace it with /etc/rc.d/rc.i2p.new as soon as possible"
141        echo -ne "\007" ; sleep 0.3
142        echo -ne "\007" ; sleep 0.3
143        echo -ne "\007" ; sleep 0.3
144        echo -ne "\007" ; sleep 0.3
145        echo -ne "\007" ; sleep 0.3
146        echo -ne "\007" ; sleep 0.3
147        echo -e "\007" ; sleep 0.3
148else
149        mv /etc/rc.d/rc.i2p.new /etc/rc.d/rc.i2p
150        echo
151        echo "Installation finished. The i2p start/stop script has been"
152        echo "installed in /etc/rc.d . You should chmod +x"
153        echo '/etc/rc.d/rc.i2p to start it on boot.'
154        echo
155fi
156
157exit
Note: See TracBrowser for help on using the repository browser.