Debian Codegraph @

builds/install/arch-specific/darwin/changeMultiConnectMode

raw
1 #!/bin/sh
2 #
3 # The contents of this file are subject to the Initial
4 # Developer's Public License Version 1.0 (the "License");
5 # you may not use this file except in compliance with the
6 # License. You may obtain a copy of the License at
7 # http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
8 #
9 # Software distributed under the License is distributed AS IS,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied.
11 # See the License for the specific language governing rights
12 # and limitations under the License.
13 #
14 # The Original Code was created by Paul Beach
15 # based on the original Posix script created by Alex Peshkov
16 # for the Firebird Open Source RDBMS project.
17 #
18 # Copyright (c) 2009 Paul Beach <[email protected]>
19 # Alex Peshkov <[email protected]>
20 # and all contributors signed below.
21 #
22 # All Rights Reserved.
23 # Contributor(s): ______________________________________.
24 #
25
26 FB_FW=/Library/Frameworks/Firebird.framework/
27 FB_RES=@prefix@/Versions/A/Resources
28
29 cat <<EOF
30 There are now two ways to support multiple connections
31 to the Firebird Classic Server.
32 multiprocess (traditional and default) and multithreaded.
33 This script allows you to switch between the two modes.
34 Choose process for normal Classic, and thread for SuperClassic.
35
36 EOF
37
38 read -p "Option: Multi-(process|thread) " multianswer
39
40 case $multianswer in
41 process)
42 # Check mode...
43 if [ ! -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
44 echo "You are already in Classic mode"
45 else
46 # Check if SuperClassic is running
47 echo "Check if SuperClassic is running"
48 if ps -axe | grep "fb_smp_server" | grep -v grep
49 then
50 echo "An instance of the Firebird SuperClassic Server seems to be running."
51 echo "Please exit all Firebird applications and shut down the server before continuing."
52 exit 1
53 fi
54 # Remove SuperClassic
55 echo "Removing SuperClassic"
56 rm -fr /Library/StartupItems/Firebird
57 rm $FB_FW/Versions/A/Resources/.SuperServer
58
59 # Install and Start Classic
60 echo "Install and start Classic"
61
62 #inetd
63 if [ -f /var/run/inetd.pid -a -d /etc/inetd.d ]; then
64 if [ -f /etc/inetd.conf ]; then
65 echo "gds_db stream tcp nowait root $FB_FW/Resources/bin/fb_smp_server fb_smp_server" > /etc/.fb.inetd.conf.entry
66 cat /etc/inetd.conf /etc/.fb.inetd.conf.entry > /etc/.firebird.temp.install.inetd.conf
67 mv /etc/.firebird.temp.install.inetd.conf /etc/inetd.conf
68 rm -f /etc/.fb.inetd.conf.entry
69 HUPNEEDED='y'
70 fi
71 fi
72
73 #xinetd
74 if [ -f /etc/xinet.d ]; then
75 cat > /etc/xinetd.d/firebird <<EOF
76 service gds_db
77 {
78 disable = no
79 socket_type = stream
80 wait = no
81 user = firebird
82 EOF
83 echo "server = $FB_FW/Resources/bin/fb_smp_server" >> /etc/xinetd.d/firebird
84 cat >> /etc/xinetd.d/firebird << EOF
85 groups = yes
86 }
87 EOF
88 HUPNEEDED='y'
89 fi
90
91 #launchd
92 cp $FB_FW/Resources/org.firebird.gds.plist /Library/LaunchDaemons/org.firebird.gds.plist
93 launchctl load /Library/LaunchDaemons/org.firebird.gds.plist
94
95 # Tell inetd/xinetd to reload their configuration files.
96 echo "hupneeded"
97 if [ "$HUPNEEDED" = 'y' ]; then
98 if [ -f /var/run/inetd.pid ]; then
99 kill -HUP `cat /var/run/inetd.pid`
100 fi
101 if [ -f /var/run/xinetd.pid ]; then
102 kill -HUP `cat /var/run/xinetd.pid`
103 fi
104 fi
105 fi
106 ;;
107
108 thread)
109 if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
110 echo "You are already in SuperClassic mode"
111 else
112 # Check if Classic is running
113 echo "Check if Classic is running"
114 if ps -axe | grep "fb_smp_server" | grep -v grep
115 then
116 echo "An instance of the Firebird Classic Server seems to be running."
117 echo "Please exit all Firebird applications before continuing."
118 fi
119 # Remove the Classic installation
120 echo "Removing the Classic installation"
121
122 #inetd (old)
123 echo "inetd"
124 if [ -f /etc/inetd.conf ]; then
125 grep -s gds_db /etc/inetd.conf > /dev/null 2>&1
126 if test $? != 0 ; then
127 cat /etc/inetd.conf | grep -v gds_db > /etc/.firebird.temp.install.inetd.conf
128 mv /etc/.firebird.temp.install.inetd.conf /etc/inetd.conf
129 HUPNEEDED='y'
130 fi
131 fi
132
133 #xinetd (pre 10.5)
134 echo "xinetd"
135 if [ -f /etc/xinetd.d/firebird ]; then
136 rm /etc/xinetd.d/firebird
137 HUPNEEDED='y'
138 fi
139
140 # Tell inetd/xinetd to reload their configuration files.
141 echo "hupneeded"
142 if [ "$HUPNEEDED" = 'y' ]; then
143 if [ -f /var/run/inetd.pid ]; then
144 kill -HUP `cat /var/run/inetd.pid`
145 fi
146 if [ -f /var/run/xinetd.pid ]; then
147 kill -HUP `cat /var/run/xinetd.pid`
148 fi
149 fi
150
151 #launchd
152 echo "launchd"
153 if [ -f /Library/LaunchDaemons/org.firebird.gds.plist ]; then
154 launchctl unload /Library/LaunchDaemons/org.firebird.gds.plist
155 rm /Library/LaunchDaemons/org.firebird.gds.plist
156 fi
157
158 # Install and start SuperClassic
159 echo "install and start SuperClassic"
160 touch $FB_FW/Versions/A/Resources/.SuperServer
161 cp -r $FB_FW/Resources/FirebirdSS /Library/StartupItems/Firebird
162 if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
163 chmod u+xg+xo+x /Library/StartupItems/Firebird/Firebird
164 /Library/StartupItems/Firebird/Firebird start
165 fi
166 fi
167 ;;
168 *)
169 echo "unknown option $multianswer chosen"
170 exit 1
171 ;;
172 esac