View | Details | Raw Unified | Return to bug 6913
Collapse All | Expand All

(-)a/debian/docs/koha-create.xml (-3 / +54 lines)
Lines 24-34 Link Here
24
  <refsynopsisdiv>
24
  <refsynopsisdiv>
25
    <cmdsynopsis>
25
    <cmdsynopsis>
26
      <command>koha-create</command>
26
      <command>koha-create</command>
27
      <arg choice="req"><option>--create-db</option>|<option>--request-db</option>|<option>--populate-db</option></arg>
27
      <arg choice="req"><option>--create-db</option>|<option>--request-db</option>|<option>--populate-db</option>|<option>--use-db</option></arg>
28
      <arg><option>--marcflavor</option> marc21|normarc|unimarc</arg>
28
      <arg><option>--marcflavor</option> marc21|normarc|unimarc</arg>
29
      <arg><option>--zebralang</option> en|nb|fr</arg>
29
      <arg><option>--zebralang</option> en|nb|fr</arg>
30
      <arg><option>--defaultsql</option> /path/to/some.sql</arg>
30
      <arg><option>--defaultsql</option> /path/to/some.sql</arg>
31
      <arg><option>--configfile</option> /path/to/config</arg>
31
      <arg><option>--configfile</option> /path/to/config</arg>
32
      <arg><option>--passwdfile</option> /path/to/passwd</arg>
33
      <arg><option>--database</option> database</arg>
32
      <arg><option>--adminuser</option> n</arg>
34
      <arg><option>--adminuser</option> n</arg>
33
      <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg>
35
      <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg>
34
    </cmdsynopsis>
36
    </cmdsynopsis>
Lines 40-46 Link Here
40
    <varlistentry>
42
    <varlistentry>
41
      <term><option>--create-db</option></term>
43
      <term><option>--create-db</option></term>
42
      <listitem>
44
      <listitem>
43
        <para>Create a new datbase on localhost. If the database you want to use does not reside on localhost, you  can  use <option>--request-db</option> and <option>--populate-db</option>, see below.</para>
45
        <para>Create a new database on localhost. If the database you want to use does not reside on localhost, you can use <option>--request-db</option> and <option>--populate-db</option>, see below. If the database already exists, you can use <option>--use-db</option>, see below.</para>
44
      </listitem>
46
      </listitem>
45
    </varlistentry>
47
    </varlistentry>
46
    
48
    
Lines 54-60 Link Here
54
    <varlistentry>
56
    <varlistentry>
55
      <term><option>--populate-db</option></term>
57
      <term><option>--populate-db</option></term>
56
      <listitem>
58
      <listitem>
57
        <para>When you have run koha-create with the <option>--request-db</option> option, and a database has been set up, you can finnish your installation by running <command>koha-create</command> with this option.</para>
59
        <para>When you have run koha-create with the <option>--request-db</option> option, and a database has been set up, you can finish your installation by running <command>koha-create</command> with this option.</para>
60
      </listitem>
61
    </varlistentry>
62
63
    <varlistentry>
64
      <term><option>--use-db</option></term>
65
      <listitem>
66
        <para>When the database you want to use has already been populated, you can run <command>koha-create</command> with this option to take care of all the other set-up configuration.</para>
58
      </listitem>
67
      </listitem>
59
    </varlistentry>
68
    </varlistentry>
60
69
Lines 66-71 Link Here
66
    </varlistentry>
75
    </varlistentry>
67
76
68
    <varlistentry>
77
    <varlistentry>
78
      <term><option>--database</option></term>
79
      <listitem>
80
        <para>MySQL database to use.</para>
81
      </listitem>
82
    </varlistentry>
83
84
    <varlistentry>
69
      <term><option>--defaultsql</option></term>
85
      <term><option>--defaultsql</option></term>
70
      <listitem>
86
      <listitem>
71
        <para>Path to an SQL-file other than the one pointed to in the default or alternative config file. Corresponds to the DEFAULTSQL config file variable.</para>
87
        <para>Path to an SQL-file other than the one pointed to in the default or alternative config file. Corresponds to the DEFAULTSQL config file variable.</para>
Lines 80-85 Link Here
80
    </varlistentry>
96
    </varlistentry>
81
97
82
    <varlistentry>
98
    <varlistentry>
99
      <term><option>--passwdfile</option></term>
100
      <listitem>
101
        <para>Path to an alternative passwd file. This file is in the same format as the default (Koha) passwd file, see below for details.</para>
102
      </listitem>
103
    </varlistentry>
104
105
    <varlistentry>
83
      <term><option>--zebralang</option></term>
106
      <term><option>--zebralang</option></term>
84
      <listitem>
107
      <listitem>
85
        <para>Primary language for Zebra indexing. Corresponds to the ZEBRA_LANGUAGE config file variable.</para>
108
        <para>Primary language for Zebra indexing. Corresponds to the ZEBRA_LANGUAGE config file variable.</para>
Lines 107-112 Link Here
107
      </varlistentry>
130
      </varlistentry>
108
    
131
    
109
      <varlistentry>
132
      <varlistentry>
133
        <term><option>OPACPORT</option></term>
134
        <listitem>
135
          <para>The port for the OPAC.</para>
136
        </listitem>
137
      </varlistentry>
138
139
      <varlistentry>
140
        <term><option>OPACPREFIX</option></term>
141
        <listitem>
142
          <para>This is inserted before the instance name  when  forming  Apache ServerName.  For subdomains, make sure it ends with a period.</para>
143
        </listitem>
144
      </varlistentry>
145
146
      <varlistentry>
147
        <term><option>OPACSUFFIX</option></term>
148
        <listitem>
149
          <para>This  is inserted after the instance name, but before the domain name, when forming Apache ServerName.</para>
150
        </listitem>
151
      </varlistentry>
152
    
153
      <varlistentry>
110
        <term><option>INTRAPORT</option></term>
154
        <term><option>INTRAPORT</option></term>
111
        <listitem>
155
        <listitem>
112
          <para>The port for the intranet.  If you set this to empty or 80, then you must also define INTRAPREFIX or INTRASUFFIX.</para>
156
          <para>The port for the intranet.  If you set this to empty or 80, then you must also define INTRAPREFIX or INTRASUFFIX.</para>
Lines 169-174 Link Here
169
        <para>Configuration variables are read from this file, if it exists.</para>
213
        <para>Configuration variables are read from this file, if it exists.</para>
170
      </listitem>
214
      </listitem>
171
    </varlistentry>
215
    </varlistentry>
216
217
    <varlistentry>
218
      <term><option><filename>/etc/koha/passwd</filename></option></term>
219
      <listitem>
220
        <para>Pre-selected database credentials are read from this file, if it exists. The format for this file is instancename:username:passwd:database. Database is optional, but the other three are required if you want to use pre-determined database user credentials.</para>
221
      </listitem>
222
    </varlistentry>
172
  </variablelist>
223
  </variablelist>
173
  </refsect1>
224
  </refsect1>
174
225
(-)a/debian/docs/koha-remove.xml (+12 lines)
Lines 24-33 Link Here
24
  <refsynopsisdiv>
24
  <refsynopsisdiv>
25
    <cmdsynopsis>
25
    <cmdsynopsis>
26
      <command>koha-remove</command>
26
      <command>koha-remove</command>
27
      <arg><option>--keep-mysql</option></arg>
27
      <arg choice="req" rep="repeat">instancename</arg>
28
      <arg choice="req" rep="repeat">instancename</arg>
28
    </cmdsynopsis>
29
    </cmdsynopsis>
29
  </refsynopsisdiv>
30
  </refsynopsisdiv>
30
31
32
  <refsect1><title>Options</title>
33
  <variablelist>
34
    <varlistentry>
35
      <term><option>--keep-mysql</option></term>
36
      <listitem>
37
        <para>Leave the MySQL database and user when removing the Koha instance.</para>
38
      </listitem>
39
    </varlistentry>
40
  </variablelist>
41
  </refsect1>
42
31
  <refsect1><title>Description</title>
43
  <refsect1><title>Description</title>
32
  <para>Remove one or more Koha instance(s). This removes all files associated with a Koha instance.</para>
44
  <para>Remove one or more Koha instance(s). This removes all files associated with a Koha instance.</para>
33
  </refsect1>
45
  </refsect1>
(-)a/debian/scripts/koha-create (-11 / +55 lines)
Lines 19-29 Link Here
19
19
20
set -e
20
set -e
21
21
22
usage="Usage: $0 [--create-db|--request-db|--populate-db] \
22
usage="Usage: $0 [--create-db|--request-db|--populate-db|--use-db] \
23
    [--marcflavor marc21|normarc|unimarc] \
23
    [--marcflavor marc21|normarc|unimarc] \
24
    [--zebralang en|nb|fr] \
24
    [--zebralang en|nb|fr] \
25
    [--defaultsql /path/to/some.sql] \
25
    [--defaultsql /path/to/some.sql] \
26
    [--configfile /path/to/config] [--adminuser n] instancename"
26
    [--configfile /path/to/config] [--passwdfile /path/to/passwd] \
27
    [--database database] [--adminuser n] instancename"
27
28
28
die() {
29
die() {
29
    echo "$@" 1>&2
30
    echo "$@" 1>&2
Lines 76-81 getinstancemysqldatabase() { Link Here
76
# Set defaults and read config file, if it exists.
77
# Set defaults and read config file, if it exists.
77
DOMAIN=""
78
DOMAIN=""
78
OPACPORT="80"
79
OPACPORT="80"
80
OPACPREFIX=""
81
OPACSUFFIX=""
79
INTRAPORT="8080"
82
INTRAPORT="8080"
80
INTRAPREFIX=""
83
INTRAPREFIX=""
81
INTRASUFFIX=""
84
INTRASUFFIX=""
Lines 83-96 DEFAULTSQL="" Link Here
83
ZEBRA_MARC_FORMAT="marc21"
86
ZEBRA_MARC_FORMAT="marc21"
84
ZEBRA_LANGUAGE="en"
87
ZEBRA_LANGUAGE="en"
85
ADMINUSER="1"
88
ADMINUSER="1"
89
PASSWDFILE="/etc/koha/passwd"
86
if [ -e /etc/koha/koha-sites.conf ]
90
if [ -e /etc/koha/koha-sites.conf ]
87
then
91
then
88
    . /etc/koha/koha-sites.conf
92
    . /etc/koha/koha-sites.conf
89
fi
93
fi
90
94
91
[ $# -ge 2 ] && [ $# -le 12 ] || die $usage
95
[ $# -ge 2 ] && [ $# -le 16 ] || die $usage
92
96
93
TEMP=`getopt -o crpm:l:d:f:a: -l create-db,request-db,populate-db,marcflavor:,zebralang:,defaultsql:,configfile:,adminuser: \
97
TEMP=`getopt -o crpm:l:d:f:a: -l create-db,request-db,populate-db,use-db,marcflavor:,zebralang:,defaultsql:,configfile:,passwdfile:,adminuser: \
94
     -n "$0" -- "$@"`
98
     -n "$0" -- "$@"`
95
99
96
# Note the quotes around `$TEMP': they are essential!
100
# Note the quotes around `$TEMP': they are essential!
Lines 107-116 while true ; do Link Here
107
		-c|--create-db) op=create ; shift ;;
111
		-c|--create-db) op=create ; shift ;;
108
		-r|--request-db) op=request ; shift ;;
112
		-r|--request-db) op=request ; shift ;;
109
		-p|--populate-db) op=populate ; shift ;;
113
		-p|--populate-db) op=populate ; shift ;;
114
        -u|--use-db) op=use ; shift ;;
110
		-m|--marcflavor) CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;;
115
		-m|--marcflavor) CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;;
111
		-l|--zebralang) CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;;
116
		-l|--zebralang) CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;;
112
		-d|--defaultsql) CLO_DEFAULTSQL="$2" ; shift 2 ;;
117
		-d|--defaultsql) CLO_DEFAULTSQL="$2" ; shift 2 ;;
113
		-f|--configfile) configfile="$2" ; shift 2 ;;
118
		-f|--configfile) configfile="$2" ; shift 2 ;;
119
        -s|--passwdfile) CLO_PASSWDFILE="$2" ; shift 2 ;;
120
        -b|--database) CLO_DATABASE="$2" ; shift 2 ;;
114
		-a|--adminuser) CLO_ADMINUSER="$2" ; shift 2 ;;
121
		-a|--adminuser) CLO_ADMINUSER="$2" ; shift 2 ;;
115
		--) shift ; break ;;
122
		--) shift ; break ;;
116
		*) die "Internal error processing command line arguments" ;;
123
		*) die "Internal error processing command line arguments" ;;
Lines 145-170 if [ "$CLO_ADMINUSER" != "" ] Link Here
145
then
152
then
146
    ADMINUSER="$CLO_ADMINUSER"
153
    ADMINUSER="$CLO_ADMINUSER"
147
fi
154
fi
155
if [ "$CLO_PASSWDFILE" != "" ]
156
then
157
    PASSWDFILE="$CLO_PASSWDFILE"
158
fi
148
159
149
name="$1"
160
name="$1"
150
161
151
opacdomain="$name$DOMAIN"
162
opacdomain="$OPACPREFIX$name$OPACSUFFIX$DOMAIN"
152
intradomain="$INTRAPREFIX$name$INTRASUFFIX$DOMAIN"
163
intradomain="$INTRAPREFIX$name$INTRASUFFIX$DOMAIN"
153
164
154
165
155
mysqldb="koha_$name"
166
if [ `cat $PASSWDFILE | grep "^$name:"` ]
167
then
168
    passwdline=`cat $PASSWDFILE | grep "^$name:"`
169
    mysqluser=`echo $passwdline | cut -d ":" -f 2`
170
    mysqlpwd=`echo $passwdline | cut -d ":" -f 3`
171
    mysqldb=`echo $passwdline | cut -d ":" -f 4`
172
fi
173
174
# The order of precedence for MySQL database name is: 
175
# default < passwd file < command line
176
if [ "$mysqldb" = "" ]
177
then
178
    mysqldb="koha_$name"
179
fi
180
if [ "$CLO_DATABASE" != "" ]
181
then
182
    mysqldb="$CLO_DATABASE"
183
fi
184
185
if [ "$mysqluser" = "" ]
186
then
187
    mysqluser="koha_$name"
188
fi
156
mysqlhost="$(getmysqlhost)"
189
mysqlhost="$(getmysqlhost)"
157
mysqluser="koha_$name"
158
190
159
if [ "$op" = create ] || [ "$op" = request ]
191
if [ "$op" = create ] || [ "$op" = request ] || [ "$op" = use ]
160
then
192
then
161
    mysqlpwd="$(pwgen -1)"
193
    if [ "$mysqlpwd" = "" ]
194
    then
195
        mysqlpwd="$(pwgen -1)"
196
    fi
162
else
197
else
163
    mysqlpwd="$(getinstancemysqlpassword $name)"
198
    mysqlpwd="$(getinstancemysqlpassword $name)"
164
fi
199
fi
165
200
166
201
167
if [ "$op" = create ] || [ "$op" = request ]
202
if [ "$op" = create ] || [ "$op" = request ] || [ "$op" = use ]
168
then
203
then
169
    # Create new user and group.
204
    # Create new user and group.
170
    username="$name-koha"
205
    username="$name-koha"
Lines 197-202 FLUSH PRIVILEGES; Link Here
197
eof
232
eof
198
    fi #`
233
    fi #`
199
234
235
    if [ "$op" = use ]
236
    then
237
        mysql --defaults-extra-file=/etc/mysql/koha-common.cnf --force <<eof
238
CREATE USER \`$mysqluser\`@'%' IDENTIFIED BY '$mysqlpwd';
239
GRANT ALL PRIVILEGES ON \`$mysqldb\`.* TO \`$mysqluser\`;
240
FLUSH PRIVILEGES;
241
eof
242
    fi #`
243
200
    # Generate and install Apache site-available file and log dir.
244
    # Generate and install Apache site-available file and log dir.
201
    generate_config_file apache-site.conf.in \
245
    generate_config_file apache-site.conf.in \
202
        "/etc/apache2/sites-available/$name"
246
        "/etc/apache2/sites-available/$name"
Lines 283-289 eof Link Here
283
fi
327
fi
284
328
285
329
286
if [ "$op" = create ] || [ "$op" = populate ]
330
if [ "$op" = create ] || [ "$op" = populate ] || [ "$op" = use ]
287
then
331
then
288
    # Reconfigure Apache.
332
    # Reconfigure Apache.
289
    a2ensite "$name"
333
    a2ensite "$name"
(-)a/debian/scripts/koha-remove (-2 / +15 lines)
Lines 19-34 Link Here
19
19
20
set -e
20
set -e
21
21
22
args=$(getopt -l keep-mysql -o k -n $0 -- "$@")
23
set -- $args
24
while [ ! -z "$1" ]
25
do
26
    case "$1" in
27
         -k|--keep-mysql) keepmysql=1; exit;;
28
          *) break;;
29
    esac
30
    shift
31
done
32
22
33
23
for name in "$@"
34
for name in "$@"
24
do
35
do
25
    echo "Removing Koha instance $name"
36
    echo "Removing Koha instance $name"
26
37
27
    mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
38
    if [ "$keepmysql" != "1" ]
39
    then
40
        mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof
28
DROP USER \`koha_$name\`;
41
DROP USER \`koha_$name\`;
29
DROP DATABASE \`koha_$name\`;
42
DROP DATABASE \`koha_$name\`;
30
FLUSH PRIVILEGES;
43
FLUSH PRIVILEGES;
31
eof
44
eof
45
    fi #`
32
    
46
    
33
    koha-stop-zebra $name
47
    koha-stop-zebra $name
34
    rm "/etc/apache2/sites-available/$name"
48
    rm "/etc/apache2/sites-available/$name"
35
- 

Return to bug 6913