Debian Codegraph @

builds/install/arch-specific/darwin/changeServerMode

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) 2017 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 DAEMONLOC=/Library/LaunchDaemons
28
29 #------------------------------------------------------------------------
30 # add a line in the (usually) /etc/services or /etc/inetd.conf file
31 # Here there are three cases, not found => add
32 # found & different => replace
33 # found & same => do nothing
34 #
35
36 replaceLineInFile() {
37 FileName="$1"
38 echo $Filename
39 newLine="$2"
40 oldLine=`grep "$3" $FileName`
41
42 if [ -z "$oldLine" ]
43 then
44 echo "$newLine" >> "$FileName"
45 elif [ "$oldLine" != "$newLine" ]
46 then
47 MakeTemp
48 grep -v "$oldLine" "$FileName" > "$TmpFile"
49 echo "$newLine" >> $TmpFile
50 cp $TmpFile $FileName
51 rm -f $TmpFile
52 echo "Updated $1"
53 fi
54 }
55
56 MakeTemp() {
57 TmpFile=`mktemp -q /tmp/firebird_tmp.XXXXXX`
58 if [ $? -ne 0 ]
59 then
60 for n in `seq 1000`
61 do
62 TmpFile=/tmp/firebird_tmp.$n
63 if [ ! -e $TmpFile ]
64 then
65 touch $TmpFile
66 return
67 fi
68 done
69 fi
70 }
71
72 cat <<EOF
73 Firebird 4.x can operate in different server modes. By default it is installed in SuperServer mode with full SMP support. However it can also run in Classic mode.
74 SuperServer offers better performance whilst Classic offers better availability.
75 This script will allow you to switch between SuperServer and the Classic variant.
76
77 Please make sure that you quit and exit all Firebird Applications before continuing
78 EOF
79
80 read -p "Option: (Classic|SuperServer) " multianswer
81
82 case $multianswer in
83 Classic)
84
85 # Check mode...
86 if [ -f "$FB_FW/Resources/Classic" ]; then
87 echo "Note: you are already in Classic mode"
88 exit 1
89 fi
90
91 launchctl unload $DAEMONLOC/org.firebird.gds.plist
92 fbconf=$FB_FW/Resources/firebird.conf
93 replaceLineInFile $fbconf "ServerMode=Classic" "ServerMode"
94
95 if [ -f "$FB_FW/Resources/SuperServer" ]; then
96 rm $FB_FW/Resources/SuperServer
97 fi
98
99 touch $FB_FW/Resources/Classic
100 chflags hidden $FB_FW/Resources/Classic
101
102 cp $FB_FW/Resources/cs.org.firebird.gds.plist $DAEMONLOC/org.firebird.gds.plist
103 launchctl load $DAEMONLOC/org.firebird.gds.plist
104 ;;
105
106 SuperServer)
107
108 # Check mode...
109 if [ -f "$FB_FW/Resources/SuperServer" ]; then
110 echo "Note: you are already in SuperServer mode"
111 exit 1
112 fi
113
114 launchctl unload $DAEMONLOC/org.firebird.gds.plist
115 fbconf=$FB_FW/Resources/firebird.conf
116 replaceLineInFile $fbconf "ServerMode=Super" "ServerMode"
117
118 if [ -f "$FB_FW/Resources/Classic" ]; then
119 rm $FB_FW/Resources/Classic
120 fi
121
122 touch $FB_FW/Resources/SuperServer
123 chflags hidden $FB_FW/Resources/SuperServer
124 cp $FB_FW/Resources/org.firebird.gds.plist $DAEMONLOC/org.firebird.gds.plist
125 launchctl load $DAEMONLOC/org.firebird.gds.plist
126 ;;
127
128 *)
129
130 echo "unknown option chosen"
131 exit 1
132 ;;
133
134 esac