Browse code

- further unification of database setup scripts - move some common variable definitions and functions out of mysql, dbtext and postgresql into openserdbctl.base file - change database setup scripts to use the variable definitions from openserctlrc, move some variable definition to this file - add installation of openserdbctl.base to Makefile - add some sed hacks to Makefile to fix paths during installation - fix some comments in Makefile.defs

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2324 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 01/06/2007 13:58:37
Showing 5 changed files
... ...
@@ -31,20 +31,51 @@
31 31
 # 2007-02-28  DB migration added (bogdan)
32 32
 #
33 33
 # 2007-05-21  Move SQL database definitions out of this script (henning)
34
+#
35
+# 2007-05-31  Move common definitions to openserdbctl.base file (henningw)
34 36
 
35 37
 PATH=$PATH:/usr/local/sbin
36 38
 
37
-# include resource files, if any
38
-if [ -f /etc/openser/.opensermysqlrc ]; then
39
-	. /etc/openser/.opensermysqlrc
39
+### include resource files, if any
40
+if [ -f /usr/local/etc/openser/openserctlrc ]; then
41
+	. /usr/local/etc/openser/openserctlrc
42
+fi
43
+if [ -f ~/.openserctlrc ]; then
44
+	. ~/.openserctlrc
40 45
 fi
41
-if [ -f /usr/local/etc/openser/.opensermysqlrc ]; then
42
-	. /usr/local/etc/openser/.opensermysqlrc
46
+if [ -f ./openserctlrc ]; then
47
+	. ./openserctlrc
48
+fi
49
+
50
+# force values for variables in this section
51
+# you better set the variables in ~/.openserctlrc
52
+if [ -z "$ETCDIR" ] ; then
53
+	ETCDIR="/usr/local/etc/openser"
43 54
 fi
44
-if [ -f ~/.opensermysqlrc ]; then
45
-	. ~/.opensermysqlrc
55
+
56
+### version for this script
57
+VERSION='1.3dev - $Revision$'
58
+
59
+if [ -z "$MYDIR" ] ; then
60
+	MYDIR=`dirname $0`
46 61
 fi
47 62
 
63
+if [ -z "$MYLIBDIR" ] ; then
64
+	MYLIBDIR="/usr/local/lib/openser/openserctl"
65
+	if [ ! -d "$MYLIBDIR" ]; then
66
+		MYLIBDIR=$MYDIR
67
+	fi
68
+fi
69
+
70
+# load base functions
71
+if [ -f "$MYLIBDIR/openserdbctl.base" ]; then
72
+	. "$MYLIBDIR/openserdbctl.base"
73
+else
74
+	echo "Cannot load core functions '$MYLIBDIR/openserdbctl.base' - exiting ..."
75
+	exit -1
76
+fi
77
+
78
+
48 79
 # path to the database schemas
49 80
 DATA_DIR="/usr/local/share/openser"
50 81
 if [ -d "$DATA_DIR/mysql" ] ; then
... ...
@@ -56,30 +87,7 @@ fi
56 56
 #################################################################
57 57
 # config vars
58 58
 #################################################################
59
-# name of the database to be used by SER
60
-if [ -z "$DBNAME" ]; then
61
-	DBNAME="openser"
62
-fi
63
-# address of MySQL server
64
-if [ -z "$DBHOST" ]; then
65
-	DBHOST="localhost"
66
-fi
67
-# user with full privileges over DBNAME database
68
-if [ -z "$DBRWUSER" ]; then
69
-	DBRWUSER="openser"
70
-fi
71
-# password user with full privileges over DBNAME database
72
-if [ -z "$DBRWPW" ]; then
73
-	DBRWPW="openserrw"
74
-fi
75
-# read-only user
76
-if [ -z "$DBROUSER" ]; then
77
-	DBROUSER="openserro"
78
-fi
79
-# password for read-only user
80
-if [ -z "$DBROPW" ]; then
81
-	DBROPW="openserro"
82
-fi
59
+
83 60
 # full privileges MySQL user
84 61
 if [ -z "$DBROOTUSER" ]; then
85 62
 	DBROOTUSER="root"
... ...
@@ -89,77 +97,9 @@ CMD="mysql -h $DBHOST -u$DBROOTUSER "
89 89
 DUMP_CMD="mysqldump -h $DBHOST -u$DBROOTUSER -c -t "
90 90
 BACKUP_CMD="mysqldump -h $DBHOST -u$DBROOTUSER -c "
91 91
 
92
-
93
-# If you change this definitions here, then you must change them 
94
-# in db/schema/entities.xml too.
95
-# FIXME
96
-
97
-# type of mysql tables
98
-if [ -z "$TABLE_TYPE" ]; then
99
-	TABLE_TYPE="TYPE=MyISAM"
100
-fi
101
-# user name column
102
-if [ -z "$USERCOL" ]; then
103
-	USERCOL="username"
104
-fi
105
-
106
-FOREVER="2020-05-28 21:32:15"
107
-
108
-DEFAULT_ALIASES_EXPIRES=$FOREVER
109
-DEFAULT_Q="1.0"
110
-DEFAULT_CALLID="Default-Call-ID"
111
-DEFAULT_CSEQ="13"
112
-DEFAULT_LOCATION_EXPIRES=$FOREVER
113
-
114
-# Program to calculate a message-digest fingerprint 
115
-if [ -z "$MD5" ]; then
116
-	MD5="md5sum"
117
-fi
118
-if [ -z "$AWK" ]; then
119
-	AWK="awk"
120
-fi
121
-if [ -z "$GREP" ]; then
122
-	GREP="egrep"
123
-fi
124
-if [ -z "$SED" ]; then
125
-	SED="sed"
126
-fi
127
-
128
-# define what modules should be installed
129
-
130
-# openser standard modules
131
-STANDARD_MODULES="standard acc lcr domain group permissions 
132
-                  registrar usrloc msilo alias_db uri_db 
133
-                  speeddial avpops auth_db pdt"
134
-
135
-# openser extra modules
136
-EXTRA_MODULES="imc cpl siptrace domainpolicy"
137 92
 #################################################################
138 93
 
139 94
 
140
-usage() {
141
-COMMAND=`basename $0`
142
-cat <<EOF
143
-usage: $COMMAND create
144
-       $COMMAND drop   (!!entirely deletes tables)
145
-       $COMMAND reinit (!!entirely deletes and than re-creates tables
146
-       $COMMAND backup (dumps current database to stdout)
147
-       $COMMAND restore <file> (restores tables from a file)
148
-       $COMMAND copy <new_db> (creates a new db from an existing one)
149
-       $COMMAND migrate <old_db> <new_db> (migrates DB from 1.1 to 1.2)
150
-       $COMMAND presence (adds the presence related tables)
151
-       $COMMAND extra (adds the extra tables - imc,cpl,siptrace,domainpolicy)
152
-       $COMMAND serweb (adds the SERWEB specific tables)
153
-
154
-       if you want to manipulate database as other MySQL user than
155
-       root, want to change database name from default value "$DBNAME",
156
-       or want to use other values for users and password, edit the
157
-       "config vars" section of the command $COMMAND
158
-
159
-EOF
160
-} #usage
161
-
162
-
163 95
 # read password
164 96
 prompt_pw()
165 97
 {
... ...
@@ -250,39 +190,12 @@ if [ $# -ne 1 ] ; then
250 250
 fi
251 251
 
252 252
 sql_query "" "drop database $1;"
253
-}
254
-
255
-
256
-# read realm
257
-prompt_realm()
258
-{
259
-	printf "Domain (realm) for the default user 'admin': "
260
-	read SIP_DOMAIN
261
-	echo
262
-}
263
-
264 253
 
265
-# calculate credentials for admin
266
-credentials()
267
-{
268
-	HA1=`echo -n "admin:$SIP_DOMAIN:$DBRWPW" | $MD5 | $AWK '{ print $1 }'`
269
-	if [ $? -ne 0 ] ; then
270
-		echo "HA1 calculation failed"
271
-		exit 1
272
-	fi
273
-	HA1B=`echo -n "admin@$SIP_DOMAIN:$SIP_DOMAIN:$DBRWPW" | $MD5 | $AWK '{ print $1 }'`
274
-	if [ $? -ne 0 ] ; then
275
-		echo "HA1B calculation failed"
276
-		exit 1
277
-	fi
278
-
279
-	#PHPLIB_ID of users should be difficulty to guess for security reasons
280
-	NOW=`date`;
281
-	PHPLIB_ID=`echo -n "$RANDOM:$NOW:$SIP_DOMAIN" | $MD5 | $AWK '{ print $1 }'`
282
-	if [ $? -ne 0 ] ; then
283
-		echo "PHPLIB_ID calculation failed"
284
-		exit 1
285
-	fi
254
+if [ $? -ne 0 ] ; then
255
+	echo "Dropping database $1 failed!"
256
+	exit 1
257
+fi
258
+echo "Database $1 deleted"
286 259
 }
287 260
 
288 261
 
... ...
@@ -467,19 +380,7 @@ fi
467 467
 
468 468
 echo "SERWEB tables succesfully created."
469 469
 
470
-echo ""
471
-echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
472
-echo "!                                                 !"
473
-echo "!                  WARNING                        !"
474
-echo "!                                                 !"
475
-echo "! There was a default admin user created:         !"
476
-echo "!    username: admin@$SIP_DOMAIN "
477
-echo "!    password: $DBRWPW "
478
-echo "!                                                 !"
479
-echo "! Please change this password or remove this user !"
480
-echo "! from the subscriber and admin_privileges table. !"
481
-echo "!                                                 !"
482
-echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
470
+serweb_message
483 471
 }  # end serweb_create
484 472
 
485 473
 
... ...
@@ -2,7 +2,7 @@
2 2
 #
3 3
 # openser control tool resource file
4 4
 #
5
-# here you can set variables used in the openserctl
5
+# here you can set variables used in the openserctl and openserdbctl
6 6
 
7 7
 ## your SIP domain
8 8
 # SIP_DOMAIN=openser.org
... ...
@@ -28,6 +28,46 @@
28 28
 ## database super user
29 29
 # DBROOTUSER="root"
30 30
 
31
+# user name column
32
+#USERCOL="username"
33
+
34
+
35
+# SQL definitions
36
+# If you change this definitions here, then you must change them 
37
+# in db/schema/entities.xml too.
38
+# FIXME
39
+
40
+#FOREVER="2020-05-28 21:32:15"
41
+#DEFAULT_ALIASES_EXPIRES=$FOREVER
42
+#DEFAULT_Q="1.0"
43
+#DEFAULT_CALLID="Default-Call-ID"
44
+#DEFAULT_CSEQ="13"
45
+#DEFAULT_LOCATION_EXPIRES=$FOREVER
46
+
47
+
48
+# Program to calculate a message-digest fingerprint 
49
+#MD5="md5sum"
50
+
51
+# awk tool
52
+# AWK="awk"
53
+
54
+# grep tool
55
+# GREP="egrep"
56
+
57
+# sed tool
58
+# SED="sed"
59
+
60
+
61
+# define what modules should be installed
62
+
63
+# openser standard modules
64
+#STANDARD_MODULES="standard acc lcr domain group permissions registrar usrloc
65
+#		   msilo alias_db uri_db speeddial avpops auth_db pdt"
66
+
67
+# openser extra modules
68
+#EXTRA_MODULES="imc cpl siptrace domainpolicy"
69
+
70
+
31 71
 ## type of aliases used: DB - database aliases; UL - usrloc aliases
32 72
 ## - default: none
33 73
 #ALIASES_TYPE="DB"
34 74
new file mode 100644
... ...
@@ -0,0 +1,159 @@
0
+PATH=$PATH:/usr/local/sbin
1
+
2
+# config vars
3
+
4
+# name of the database to be used by OpenSER
5
+if [ -z "$DBNAME" ]; then
6
+	DBNAME="openser"
7
+fi
8
+# address of database server
9
+if [ -z "$DBHOST" ]; then
10
+	DBHOST="localhost"
11
+fi
12
+# user with full privileges over DBNAME database
13
+if [ -z "$DBRWUSER" ]; then
14
+	DBRWUSER="openser"
15
+fi
16
+# password user with full privileges over DBNAME database
17
+if [ -z "$DBRWPW" ]; then
18
+	DBRWPW="openserrw"
19
+fi
20
+# read-only user
21
+if [ -z "$DBROUSER" ]; then
22
+	DBROUSER="openserro"
23
+fi
24
+# password for read-only user
25
+if [ -z "$DBROPW" ]; then
26
+	DBROPW="openserro"
27
+fi
28
+
29
+# user name column
30
+if [ -z "$USERCOL" ]; then
31
+	USERCOL="username"
32
+fi
33
+
34
+# SQL definitions
35
+# If you change this definitions here, then you must change them
36
+# in db/schema/entities.xml too.
37
+# FIXME
38
+
39
+if [ -z "$FOREVER" ] ; then
40
+	FOREVER="2020-05-28 21:32:15"
41
+fi
42
+if [ -z "$DEFAULT_ALIASES_EXPIRES" ] ; then
43
+	DEFAULT_ALIASES_EXPIRES=$FOREVER
44
+fi
45
+if [ -z "$DEFAULT" ] ; then
46
+	DEFAULT_Q="1.0"
47
+fi 
48
+if [ -z "$DEFAULT_CALLID" ] ; then
49
+	DEFAULT_CALLID="Default-Call-ID"
50
+fi
51
+if [ -z "$DEFAULT_CSEQ" ] ; then
52
+	DEFAULT_CSEQ="13"
53
+fi
54
+if [ -z "$DEFAULT_LOCATION_EXPIRES" ] ; then
55
+	DEFAULT_LOCATION_EXPIRES=$FOREVER
56
+fi
57
+
58
+
59
+# Program to calculate a message-digest fingerprint 
60
+if [ -z "$MD5" ]; then
61
+	MD5="md5sum"
62
+fi
63
+if [ -z "$AWK" ]; then
64
+	AWK="awk"
65
+fi
66
+if [ -z "$GREP" ]; then
67
+	GREP="egrep"
68
+fi
69
+if [ -z "$SED" ]; then
70
+	SED="sed"
71
+fi
72
+
73
+# define what modules should be installed
74
+if [ -z "$STANDARD_MODULES" ] ; then
75
+	STANDARD_MODULES="standard acc lcr domain group permissions registrar
76
+			  usrloc msilo alias_db uri_db speeddial avpops auth_db pdt"
77
+fi
78
+if [ -z "$EXTRA_MODULES" ] ; then
79
+	EXTRA_MODULES="imc cpl siptrace domainpolicy"
80
+fi
81
+
82
+############################################################
83
+
84
+# common functions
85
+
86
+usage() {
87
+COMMAND=`basename $0`
88
+cat <<EOF
89
+usage: $COMMAND create
90
+       $COMMAND drop   (!!entirely deletes tables)
91
+       $COMMAND reinit (!!entirely deletes and than re-creates tables
92
+       $COMMAND backup (dumps current database to stdout)
93
+       $COMMAND restore <file> (restores tables from a file)
94
+       $COMMAND copy <new_db> (creates a new db from an existing one)
95
+       $COMMAND migrate <old_db> <new_db> (migrates DB from 1.1 to 1.2)
96
+       $COMMAND presence (adds the presence related tables)
97
+       $COMMAND extra (adds the extra tables - imc,cpl,siptrace,domainpolicy)
98
+       $COMMAND serweb (adds the SERWEB specific tables)
99
+
100
+       if you want to manipulate database as other MySQL user than
101
+       root, want to change database name from default value "$DBNAME",
102
+       or want to use other values for users and password, edit the
103
+       "config vars" section of the command $COMMAND
104
+
105
+EOF
106
+} #usage
107
+
108
+
109
+
110
+
111
+# read realm
112
+prompt_realm()
113
+{
114
+	printf "Domain (realm) for the default user 'admin': "
115
+	read SIP_DOMAIN
116
+	echo
117
+}
118
+
119
+
120
+# calculate credentials for admin
121
+credentials()
122
+{
123
+	HA1=`echo -n "admin:$SIP_DOMAIN:$DBRWPW" | $MD5 | $AWK '{ print $1 }'`
124
+	if [ $? -ne 0 ] ; then
125
+		echo "HA1 calculation failed"
126
+		exit 1
127
+	fi
128
+	HA1B=`echo -n "admin@$SIP_DOMAIN:$SIP_DOMAIN:$DBRWPW" | $MD5 | $AWK '{ print $1 }'`
129
+	if [ $? -ne 0 ] ; then
130
+		echo "HA1B calculation failed"
131
+		exit 1
132
+	fi
133
+
134
+	#PHPLIB_ID of users should be difficulty to guess for security reasons
135
+	NOW=`date`;
136
+	PHPLIB_ID=`echo -n "$RANDOM:$NOW:$SIP_DOMAIN" | $MD5 | $AWK '{ print $1 }'`
137
+	if [ $? -ne 0 ] ; then
138
+		echo "PHPLIB_ID calculation failed"
139
+		exit 1
140
+	fi
141
+}
142
+
143
+# success message for serweb
144
+serweb_message()
145
+{
146
+	echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
147
+	echo "!                                                 !"
148
+	echo "!                  WARNING                        !"
149
+	echo "!                                                 !"
150
+	echo "! There was a default admin user created:         !"
151
+	echo "!    username: admin@$SIP_DOMAIN "
152
+	echo "!    password: $DBRWPW  "
153
+	echo "!                                                 !"
154
+	echo "! Please change this password or remove this user !"
155
+	echo "! from the subscriber and admin_privileges table. !"
156
+	echo "!                                                 !"
157
+	echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
158
+}
... ...
@@ -50,20 +50,48 @@
50 50
 #             and fix permissions for the SERIAL sequences.
51 51
 #
52 52
 # 2007-05-21  Move SQL database definitions out of this script (henning)
53
+#
54
+# 2007-05-31  Move common definitions to openserdbctl.base file (henningw)
53 55
 
56
+PATH=$PATH:/usr/local/sbin
54 57
 
58
+### include resource files, if any
59
+if [ -f /usr/local/etc/openser/openserctlrc ]; then
60
+	. /usr/local/etc/openser/openserctlrc
61
+fi
62
+if [ -f ~/.openserctlrc ]; then
63
+	. ~/.openserctlrc
64
+fi
65
+if [ -f ./openserctlrc ]; then
66
+	. ./openserctlrc
67
+fi
55 68
 
56
-PATH=$PATH:/usr/local/sbin
69
+# force values for variables in this section
70
+# you better set the variables in ~/.openserctlrc
71
+if [ -z "$ETCDIR" ] ; then
72
+	ETCDIR="/usr/local/etc/openser"
73
+fi
57 74
 
58
-# include resource files, if any
59
-if [ -f /etc/openser/.openserpostgresqlrc ]; then
60
-	. /etc/openser/.openserpostgresqlrc
75
+### version for this script
76
+VERSION='1.3dev - $Revision$'
77
+
78
+if [ -z "$MYDIR" ] ; then
79
+	MYDIR=`dirname $0`
61 80
 fi
62
-if [ -f /usr/local/etc/openser/.openserpostgresqlrc ]; then
63
-	. /usr/local/etc/openser/.openserpostgresqlrc
81
+
82
+if [ -z "$MYLIBDIR" ] ; then
83
+	MYLIBDIR="/usr/local/lib/openser/openserctl"
84
+	if [ ! -d "$MYLIBDIR" ]; then
85
+		MYLIBDIR=$MYDIR
86
+	fi
64 87
 fi
65
-if [ -f ~/.openserpostgresqlrc ]; then
66
-	. ~/.openserpostgresqlrc
88
+
89
+# load base functions
90
+if [ -f "$MYLIBDIR/openserdbctl.base" ]; then
91
+	. "$MYLIBDIR/openserdbctl.base"
92
+else
93
+	echo "Cannot load core functions '$MYLIBDIR/openserdbctl.base' - exiting ..."
94
+	exit -1
67 95
 fi
68 96
 
69 97
 # path to the database schemas
... ...
@@ -77,30 +105,7 @@ fi
77 77
 #################################################################
78 78
 # config vars
79 79
 #################################################################
80
-# name of the database to be used by SER
81
-if [ -z "$DBNAME" ]; then
82
-	DBNAME="openser"
83
-fi
84
-# address of Postgres server
85
-if [ -z "$DBHOST" ]; then
86
-	DBHOST="localhost"
87
-fi
88
-# user with full privileges over DBNAME database
89
-if [ -z "$DBRWUSER" ]; then
90
-	DBRWUSER="openser"
91
-fi
92
-# password user with full privileges over DBNAME database
93
-if [ -z "$DBRWPW" ]; then
94
-	DBRWPW="openserrw"
95
-fi
96
-# read-only user
97
-if [ -z "$DBROUSER" ]; then
98
-	DBROUSER="openserro"
99
-fi
100
-# password for read-only user
101
-if [ -z "$DBROPW" ]; then
102
-	DBROPW="openserro"
103
-fi
80
+
104 81
 # full privileges Postgres user
105 82
 if [ -z "$DBROOTUSER" ]; then
106 83
 	DBROOTUSER="postgres"
... ...
@@ -116,35 +121,6 @@ CMD="psql -h $DBHOST -U $DBROOTUSER "
116 116
 #   DUMP_CMD="pg_dump -h $DBHOST -u$DBROOTUSER -c -t "
117 117
 #   BACKUP_CMD="mysqldump -h $DBHOST -u$DBROOTUSER -c "
118 118
 
119
-# type of sql tables
120
-if [ -z "$TABLE_TYPE" ]; then
121
-	TABLE_TYPE=""
122
-fi
123
-# user name column
124
-if [ -z "$USERCOL" ]; then
125
-	USERCOL="username"
126
-fi
127
-
128
-# Program to calculate a message-digest fingerprint 
129
-if [ -z "$MD5" ]; then
130
-	MD5="md5sum"
131
-fi
132
-if [ -z "$AWK" ]; then
133
-	AWK="awk"
134
-fi
135
-
136
-# if you change this definitions here, then you must change them 
137
-# in db/schema/entities.xml too.
138
-# FIXME
139
-DUMMY_DATE="1900-01-01 00:00:01"
140
-FOREVER="2020-05-28 21:32:15"
141
-
142
-DEFAULT_ALIASES_EXPIRES=$FOREVER
143
-DEFAULT_Q="1.0"
144
-DEFAULT_CALLID="Default-Call-ID"
145
-DEFAULT_CSEQ="42"
146
-DEFAULT_LOCATION_EXPIRES=$FOREVER
147
-
148 119
 #################################################################
149 120
 
150 121
 
... ...
@@ -239,51 +215,21 @@ sql_query $1 < $2
239 239
 
240 240
 openser_drop()  # pars: <database name>
241 241
 {
242
-	if [ $# -ne 1 ] ; then
243
-		echo "openser_drop function takes two params"
244
-		exit 1
245
-	fi
242
+if [ $# -ne 1 ] ; then
243
+	echo "openser_drop function takes two params"
244
+	exit 1
245
+fi
246 246
 
247
-	# postgresql users are not dropped automatically
248
-	DROP_USER="DROP USER \"$DBRWUSER\";
249
-	           DROP USER \"$DBROUSER\";"
247
+# postgresql users are not dropped automatically
248
+sql_query "template1" "drop database $1; drop user \"$DBRWUSER\"; drop user \"$DBROUSER\";"
250 249
 
251
-	sql_query << EOF
252
-	drop database $1;
253
-	$DROP_USER
254
-EOF
250
+if [ $? -ne 0 ] ; then
251
+	echo "Dropping database $1 failed!"
252
+	exit 1
253
+fi
254
+echo "Database $1 dropped"
255 255
 } #openser_drop
256 256
 
257
-# read realm
258
-prompt_realm()
259
-{
260
-	printf "Domain (realm) for the default user 'admin': "
261
-	read SIP_DOMAIN
262
-	echo
263
-}
264
-
265
-# calculate credentials for admin
266
-credentials()
267
-{
268
-	HA1=`echo -n "admin:$SIP_DOMAIN:$DBRWPW" | $MD5 | $AWK '{ print $1 }'`
269
-	if [ $? -ne 0 ] ; then
270
-		echo "HA1 calculation failed"
271
-		exit 1
272
-	fi
273
-	HA1B=`echo -n "admin@$SIP_DOMAIN:$SIP_DOMAIN:$DBRWPW" | $MD5 | $AWK '{ print $1 }'`
274
-	if [ $? -ne 0 ] ; then
275
-		echo "HA1B calculation failed"
276
-		exit 1
277
-	fi
278
-
279
-	#PHPLIB_ID of users should be difficulty to guess for security reasons
280
-	NOW=`date`;
281
-	PHPLIB_ID=`echo -n "$RANDOM:$NOW:$SIP_DOMAIN" | $MD5 | $AWK '{ print $1 }'`
282
-	if [ $? -ne 0 ] ; then
283
-		echo "PHPLIB_ID calculation failed"
284
-		exit 1
285
-	fi
286
-}
287 257
 
288 258
 openser_create () # pars: <database name>
289 259
 {
... ...
@@ -292,15 +238,6 @@ if [ $# -ne 1 ] ; then
292 292
 	exit 1
293 293
 fi
294 294
 
295
-# define what modules should be installed
296
-# openser standard modules
297
-STANDARD_MODULES="standard acc lcr domain group permissions
298
-                  registrar usrloc msilo alias_db uri_db
299
-                  speeddial avpops auth_db pdt"
300
-
301
-# openser extra modules
302
-EXTRA_MODULES="imc cpl siptrace domainpolicy"
303
-
304 295
 echo "creating database $1 ..."
305 296
 
306 297
 sql_query "template1" "create database $1;"
... ...
@@ -521,7 +458,7 @@ if [ -z "$NO_USER_INIT" ] ; then
521 521
 			phone, email_address, datetime_created, datetime_modified, confirmation,
522 522
 			flag, sendnotification, greeting, ha1, domain, ha1b, phplib_id )
523 523
 			VALUES ( 'admin', '$DBRWPW', 'Initial', 'Admin', '123', 'root@localhost', 
524
-			'2002-09-04 19:37:45', '$DUMMY_DATE', '57DaSIPuCm52UNe54LF545750cfdL48OMZfroM53',
524
+			'2002-09-04 19:37:45', '1900-01-01 00:00:01', '57DaSIPuCm52UNe54LF545750cfdL48OMZfroM53',
525 525
 			'o', '', '', '$HA1', '$SIP_DOMAIN', '$HA1B', '$PHPLIB_ID' );
526 526
 			INSERT INTO admin_privileges ($USERCOL, domain, priv_name, priv_value)
527 527
 			VALUES ('admin', '$SIP_DOMAIN', 'is_admin', '1');
... ...
@@ -535,9 +472,9 @@ if [ -z "$NO_USER_INIT" ] ; then
535 535
 fi
536 536
 
537 537
 # emulate mysql proprietary functions used by the serweb in postgresql
538
-sql_query "$1" "CREATE FUNCTION "truncate" (numeric,int) RETURNS numeric AS 'SELECT trunc(\$1,\$2);' LANGUAGE 'sql';
539
-		create function unix_timestamp(timestamp) returns integer as 'select date_part(''epoch'', \$1)::int4 
540
-		as result' language 'sql';"
538
+sql_query "$1" "CREATE FUNCTION truncate(numeric, int) RETURNS numeric AS 'SELECT trunc(\$1,\$2);' LANGUAGE 'sql';
539
+		CREATE FUNCTION unix_timestamp(timestamp) RETURNS integer AS 'SELECT date_part(''epoch'', \$1)::int4 
540
+		AS result' LANGUAGE 'sql';"
541 541
 
542 542
 if [ $? -ne 0 ] ; then
543 543
 	echo "Failed to create mysql emulation functions for serweb!"
... ...
@@ -545,20 +482,8 @@ if [ $? -ne 0 ] ; then
545 545
 fi
546 546
 
547 547
 echo "SERWEB tables succesfully created."
548
-echo ""
549
-echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
550
-echo "!                                                 !"
551
-echo "!                  WARNING                        !"
552
-echo "!                                                 !"
553
-echo "! There was a default admin user created:         !"
554
-echo "!    username: admin@$SIP_DOMAIN "
555
-echo "!    password: $DBRWPW  "
556
-echo "!                                                 !"
557
-echo "! Please change this password or remove this user !"
558
-echo "! from the subscriber and admin_privileges table. !"
559
-echo "!                                                 !"
560
-echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
561 548
 
549
+serweb_message
562 550
 }  # end serweb_create
563 551
 
564 552
 
... ...
@@ -8,58 +8,56 @@
8 8
 # History:
9 9
 # 2007-02-14  Branch from mysqldb.sh script and adapt minimal capabilities(Cesc Santasusana)
10 10
 #
11
+# 2007-05-31  Move common definitions to openserdbctl.base file (henningw)
11 12
 
12 13
 PATH=$PATH:/usr/local/sbin
13 14
 
14 15
 ### include resource files, if any
15
-if [ -f /etc/openser/.openscdbtextrc ]; then
16
-	. /etc/openser/.openscdbtextrc
16
+if [ -f /usr/local/etc/openser/openserctlrc ]; then
17
+	. /usr/local/etc/openser/openserctlrc
17 18
 fi
18
-if [ -f /usr/local/etc/openser/.openscdbtextrc ]; then
19
-	. /usr/local/etc/openser/.openscdbtextrc
19
+if [ -f ~/.openserctlrc ]; then
20
+	. ~/.openserctlrc
20 21
 fi
21
-if [ -f ~/.openscdbtextrc ]; then
22
-	. ~/.openscdbtextrc
22
+if [ -f ./openserctlrc ]; then
23
+	. ./openserctlrc
23 24
 fi
24
-
25
-#################################################################
26
-# config vars
27
-#################################################################
28
-# Default PATH to the DBTEXT folder where the files are
29
-if [ -z "$DBTEXT_PATH" ]; then
30
-	DBTEXT_PATH="/usr/local/etc/openser/dbtext"
25
+  	
26
+# force values for variables in this section
27
+# you better set the variables in ~/.openserctlrc
28
+if [ -z "$ETCDIR" ] ; then
29
+	ETCDIR="/usr/local/etc/openser"
31 30
 fi
32
-#################################################################
33
-#################################################################
34 31
 
35
-# user name column
36
-if [ -z "$USERCOL" ]; then
37
-	USERCOL="username"
38
-fi
32
+### version for this script
33
+VERSION='1.3dev - $Revision$'
39 34
 
40
-# Program to calculate a message-digest fingerprint 
41
-if [ -z "$MD5" ]; then
42
-	MD5="md5sum"
43
-fi
44
-if [ -z "$AWK" ]; then
45
-	AWK="awk"
35
+if [ -z "$MYDIR" ] ; then
36
+	MYDIR=`dirname $0`
46 37
 fi
47
-if [ -z "$GREP" ]; then
48
-	GREP="egrep"
38
+
39
+if [ -z "$MYLIBDIR" ] ; then
40
+	MYLIBDIR="/usr/local/lib/openser/openserctl"
41
+	if [ ! -d "$MYLIBDIR" ]; then
42
+		MYLIBDIR=$MYDIR
43
+	fi
49 44
 fi
50
-if [ -z "$SED" ]; then
51
-	SED="sed"
45
+
46
+# load base functions
47
+if [ -f "$MYLIBDIR/openserdbctl.base" ]; then
48
+	. "$MYLIBDIR/openserdbctl.base"
49
+else
50
+	echo "Cannot load core functions '$MYLIBDIR/openserdbctl.base' - exiting ..."
51
+	exit -1
52 52
 fi
53 53
 
54
-FOREVER="2020-05-28 21:32:15"
55 54
 
56
-DEFAULT_ALIASES_EXPIRES=$FOREVER
57
-DEFAULT_Q="1.0"
58
-DEFAULT_CALLID="Default-Call-ID"
59
-DEFAULT_CSEQ="13"
60
-DEFAULT_LOCATION_EXPIRES=$FOREVER
55
+# Default PATH to the DBTEXT folder where the files are
56
+if [ -z "$DBTEXT_PATH" ]; then
57
+	DBTEXT_PATH="/usr/local/etc/openser/dbtext"
58
+fi
59
+
61 60
 
62
-#################################################################
63 61
 
64 62
 
65 63
 usage() {