ubuntu package: fixed misc bugs
[openemr.git] / contrib / util / ubuntu_package_scripts / production / postinst
blob7d53f3a269a699314cc1309e8939c3a89e8b849c
1 #!/bin/bash -e
3 #This program is free software; you can redistribute it and/or modify
4 #it under the terms of the GNU General Public License as published by
5 #the Free Software Foundation; either version 2 of the License, or
6 #(at your option) any later version.
8 # Copyright 2011
9 # authors: Amalu Obinna <amaluobinna@aol.com>
10 # Brady Miller <brady@sparmy.com>
12 # Debian package post installation script steps:
13 # 1) Collect setting from package configuration file
14 # 2) Install or Upgrade
15 # -Install
16 # a) Collect the MySQL root password (if possible)
17 # b) Ensure OpenEMR MySQL database and user do not exist. (if applicable)
18 # c) Configure OpenEMR (if applicable)
19 # d) Configure Apache
20 # e) Configure PHP
21 # -Upgrade
22 # a) Modify new OpenEMR version configuration files
23 # b) Upgrade MySQL database
24 # c) Upgrade Access Controls
25 # d) Copy over old configuration files
26 # (Copy to files with .OLD extension to allow manual comparisons by user)
27 # 3) Modify permissions for writable directories
28 # 4) Secure the php installation/upgrading scripts (if applicable)
29 # 5) Modify the package configuration file
30 # 6) Display instructions on starting openemr
32 # summary of how this script can be called:
33 # * <postinst> `configure' <most-recently-configured-version>
34 # * <old-postinst> `abort-upgrade' <new version>
35 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
36 # <new-version>
37 # * <postinst> `abort-remove'
38 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
39 # <failed-install-package> <version> `removing'
40 # <conflicting-package> <version>
41 # for details, see http://www.debian.org/doc/debian-policy/ or
42 # the debian-policy package
44 # Source debconf library.
45 . /usr/share/debconf/confmodule
47 case "$1" in
48 configure)
50 #constants and paths
51 LOGDIR=/var/log/openemr
52 LOG=$LOGDIR/install
53 CONFIGDIR=/etc/openemr
54 CONFIG=$CONFIGDIR/openemr.conf
55 TMPDIR=/tmp/openemr-tmp
56 WEB=/var/www
57 OPENEMR=$WEB/openemr
58 SITEDIR=$OPENEMR/sites/default
59 #hardcoded mysql user and database for install (not pertinent for upgrading)
60 # upgrading can use whatever is found in openemr/library/sqlconf.php
61 INSTALL_USER=openemr
62 INSTALL_DATABASE=openemr
63 #auto install scripts
64 INST=$OPENEMR/contrib/util/installScripts/InstallerAuto.php
65 INSTTEMP=$OPENEMR/contrib/util/installScripts/InstallerAutoTemp.php
66 #php and apache files
67 PHP=/etc/php5/apache2/php.ini
68 APACHE=/etc/apache2/httpd.conf
69 #web user and group
70 WEB_GROUP=www-data
71 WEB_USER=www-data
73 #Standardized echo function to send to only log file
74 # requires one parameter (string)
75 log_only () {
76 echo "`date`: $1" >> $LOG
79 #Standardized exit functions to be used
80 # requires one parameter (string with reason for exiting)
81 unable_exit () {
82 echo "`date`: $1" >> $LOG
83 echo "`date`: EXITING.........." >> $LOG
84 exit 1
87 #function to check mysql for selected databases
88 # 1st param is password, 2nd param database, 3rd param is host (optional), 4th param is user (optional)
89 check_mysql () {
90 if [ -n "$3" ]; then
91 HOST=$3
92 else
93 HOST=localhost
95 if [ -n "$4" ]; then
96 USE=$4
97 else
98 USE=root
101 if [ "`mysql -u "$USE" -h "$HOST" --password="$1" -e 'show databases' 2>/dev/null | awk '{ print $1}' | grep "^$2$"`" == "$2" ]; then
102 return 0
103 else
104 return 1
108 #function to collect variables from config files
109 # 1st param is variable name, 2nd param is filename
110 collect_var () {
111 echo `grep -i "^[[:space:]]*$1[[:space:]=]" $2 | cut -d \= -f 2 | cut -d \; -f 1 | sed "s/[ '\"]//gi"`
114 #function to insert variables into config files
115 # 1st param is variable name, 2nd param is variable, 3rd param is filename
116 insert_var () {
117 sed -i 's@^[ ]*'"$1"'[ =].*$@'"$1"' = '"$2"'@' "$3"
120 #function to prompt for input
121 # 1st param is name, 2nd param is priority, 3rd param is where result gets sent back in
122 # return the input
123 prompt_input () {
124 db_set "$1" ""
125 db_fset "$1" seen false
126 db_input "$2" "$1" || true
127 db_go || true
128 db_get "$1"
129 local input_value="$RET"
130 db_set "$1" ""
131 db_fset "$1" seen false
132 local __result=$3
133 eval $__result="'$input_value'"
136 #collect scripting information from config file
137 PROCESS=$(collect_var process $CONFIG)
138 PLAN=$(collect_var plan $CONFIG)
140 #Don't allow re-configuration
141 if [ "$PROCESS" == "complete" ] ; then
142 unable_exit "OpenEMR has already been configured."
143 elif [ "$PROCESS" == "pending" ] ; then
144 #continue with configuration
145 log_only "Configuring package..."
146 else
147 unable_exit "Error reading process variable in configuration file."
150 if [ "$PLAN" == "upgrade" ] ; then
151 #continue with upgrade
153 #collect more information from config file
154 OLD_VERSION=$(collect_var previous_version $CONFIG)
155 SQLLOCATION=$(collect_var sqllocation $CONFIG)
156 SQLUSER=$(collect_var sqluser $CONFIG)
157 SQLPASSWORD=$(collect_var sqlpassword $CONFIG)
158 SQLDATABASE=$(collect_var sqldatabase $CONFIG)
159 SQLUTFFLAG=$(collect_var sqlutfflag $CONFIG)
161 #configure openemr/sites/default/sqlconf.php
162 insert_var "\$host" "\'$SQLLOCATION\';" $SITEDIR/sqlconf.php
163 insert_var "\$login" "\'$SQLUSER\';" $SITEDIR/sqlconf.php
164 insert_var "\$pass" "\'$SQLPASSWORD\';" $SITEDIR/sqlconf.php
165 insert_var "\$dbase" "\'$SQLDATABASE\';" $SITEDIR/sqlconf.php
166 insert_var "\$disable_utf8_flag" "$SQLUTFFLAG;" $SITEDIR/sqlconf.php
167 sed -i "s/^[ ]*\$config[ =].*0/\$config = 1/" $SITEDIR/sqlconf.php
169 #before run scripts, go to openemr directory
170 cd $OPENEMR
172 #upgrade the sql database
173 CONC_VERSION=$(echo $OLD_VERSION | cut -d \- -f 1)
174 echo "<?php \$_GET['site'] = 'default'; ?>" > $OPENEMR/TEMPsql_upgrade.php
175 cat $OPENEMR/sql_upgrade.php >> $OPENEMR/TEMPsql_upgrade.php
176 sed -i "/input type='submit'/d" $OPENEMR/TEMPsql_upgrade.php
177 sed -i "s/!empty(\$_POST\['form_submit'\])/empty(\$_POST\['form_submit'\])/" $OPENEMR/TEMPsql_upgrade.php
178 sed -i "s/^[ ]*\$form_old_version[ =].*$/\$form_old_version = \"$CONC_VERSION\";/" $OPENEMR/TEMPsql_upgrade.php
179 php -f $OPENEMR/TEMPsql_upgrade.php >> $LOG
180 rm -f $OPENEMR/TEMPsql_upgrade.php
182 #upgrade the gacl controls
183 echo "<?php \$_GET['site'] = 'default'; ?>" > $OPENEMR/TEMPacl_upgrade.php
184 cat $OPENEMR/acl_upgrade.php >> $OPENEMR/TEMPacl_upgrade.php
185 php -f $OPENEMR/TEMPacl_upgrade.php >> $LOG
186 rm -f $OPENEMR/TEMPacl_upgrade.php
188 #copy the old config file into new with the OLD at end to allow manual configuration of old
189 # optional settings.
190 if [ -d $TMPDIR/openemr_web_$OLD_VERSION/sites/default ]; then
191 cp -f $TMPDIR/openemr_web_$OLD_VERSION/sites/default/config.php $SITEDIR/config.php.OLD
192 else
193 cp -f $TMPDIR/openemr_web_$OLD_VERSION/includes/config.php $SITEDIR/config.php.OLD
196 # if site-specific directories are in the old locations, move them.
197 if [ -d $OPENEMR/documents ]; then
198 mv -f $OPENEMR/documents/* $SITEDIR/documents/
199 rm -rf $OPENEMR/documents
201 if [ -d $OPENEMR/era ]; then
202 mv -f $OPENEMR/era/* $SITEDIR/era/
203 rm -rf $OPENEMR/era
205 if [ -d $OPENEMR/edi ]; then
206 mv -f $OPENEMR/edi/* $SITEDIR/edi/
207 rm -rf $OPENEMR/edi
209 if [ -d $OPENEMR/custom/letter_templates ]; then
210 mv -f $OPENEMR/custom/letter_templates/* $SITEDIR/letter_templates/
211 rm -rf $OPENEMR/custom/letter_templates
214 #secure openemr
215 chown -Rf root:root $OPENEMR
216 chmod 600 $OPENEMR/acl_setup.php
217 chmod 600 $OPENEMR/acl_upgrade.php
218 chmod 600 $OPENEMR/sl_convert.php
219 chmod 600 $OPENEMR/setup.php
220 chmod 600 $OPENEMR/sql_upgrade.php
221 chmod 600 $OPENEMR/ippf_upgrade.php
222 chmod 600 $OPENEMR/gacl/setup.php
223 chmod 600 $OPENEMR/admin.php
225 #set writable directories
226 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/documents
227 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/edi
228 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/era
229 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/library/freeb
230 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/letter_templates
231 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/cache
232 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/compiled
233 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/gacl/admin/templates_c
235 #update config file, change process to complete and remove others
236 sed -i "s/^[ ]*process[ =].*$/process=complete/" $CONFIG
237 sed -i "/^[ ]*plan[ =].*$/d" $CONFIG
238 sed -i "/^[ ]*previous_version[ =].*$/d" $CONFIG
239 sed -i "/^[ ]*sqllocation[ =].*$/d" $CONFIG
240 sed -i "/^[ ]*sqluser[ =].*$/d" $CONFIG
241 sed -i "/^[ ]*sqlpassword[ =].*$/d" $CONFIG
242 sed -i "/^[ ]*sqldatabase[ =].*$/d" $CONFIG
243 sed -i "/^[ ]*sqlutfflag[ =].*$/d" $CONFIG
245 #done upgrading
246 prompt_input openemr/success_upgrade critical ret_result
247 log_only "OpenEMR upgrade is complete."
248 log_only "Recommend setting optional configuration settings in:"
249 log_only "$SITEDIR/config.php"
250 log_only "(We have renamed your old configuration files to *.OLD)"
251 log_only "(We recommend you delete the *.OLD files when done)"
252 log_only "We have placed backup of your old OpenEMR in $TMPDIR"
253 log_only "(We recommend you copy this somewhere protected since it"
254 log_only "contains confidential patient information)"
256 exit 0
258 elif [ "$PLAN" == "install" ] ; then
259 #continue with installation
260 log_only "Installing OpenEMR"
261 else
262 unable_exit "Error reading plan variable in configuration file."
265 #collect the mysql root password (if applicable)
266 MPASS=""
267 if check_mysql "$MPASS" "mysql"; then
268 log_only "Passed the mysql check loop"
269 else
270 #the blank initial mysql password didn't work, so prompt for password
271 # (will give 3 chances to provide correct password)
272 COUNTDOWN=1
273 while true; do
274 prompt_input openemr/mysql_p_install_${COUNTDOWN} critical ret_result
275 MPASS="$ret_result"
276 if check_mysql "$MPASS" "mysql"; then
277 #the mysql root password works, so can exit loop
278 log_only "Passed the mysql check loop"
279 break
280 else
281 #the mysql root password did not work
282 if [ "$COUNTDOWN" -ge "3" ]; then
283 prompt_input openemr/no_configure_mysql_root high ret_result
284 log_only "Will install OpenEMR, however will not configure OpenEMR. (unable to provide root password)"
285 break
288 let "COUNTDOWN += 1"
289 done
292 #decide whether to configure OpenEMR after it is installed
293 configure_flag=true
294 if check_mysql "$MPASS" "mysql"; then
295 #before auto configuration, ensure the openemr user and database do not exist
296 # Check for openemr database in mysql, if exist then will not configure
297 if check_mysql "$MPASS" "$INSTALL_DATABASE"; then
298 prompt_input openemr/no_configure_mysql_database high ret_result
299 log_only "Will install OpenEMR, however will not automatically configure OpenEMR. (MySQL database already exists)"
300 configure_flag=false;
302 # Check for OpenEMR user in mysql.user, if exist then will not configure
303 USER=$(mysql -s -u root -h localhost --password="$MPASS" -e "SELECT User from mysql.user where User='$INSTALL_USER'")
304 if [ "$USER" == "$INSTALL_USER" ]; then
305 prompt_input openemr/no_configure_mysql_user high ret_result
306 log_only "Will install OpenEMR, however will not automatically configure OpenEMR. (MySQL user already exists)"
307 configure_flag=false;
309 else
310 #the mysql root password didn't work, so do not configure OpenEMR
311 log_only "Will install OpenEMR, however will not automatically configure OpenEMR. (root password did not work)"
312 configure_flag=false;
315 #go to openemr directory
316 cd $OPENEMR
318 #secure openemr
319 chown -Rf root:root $OPENEMR
321 #INSTALL/CONFIGURE OPENEMR
322 # Install openemr
323 if $configure_flag; then
324 log_only "Installing/Configuring OpenEMR..."
325 else
326 log_only "Installing OpenEMR ..."
329 # Set file and directory permissions
330 chmod 666 $SITEDIR/sqlconf.php
331 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/documents
332 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/edi
333 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/era
334 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/library/freeb
335 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/letter_templates
336 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/cache
337 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/compiled
338 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/gacl/admin/templates_c
340 if $configure_flag; then
341 # Create a random password for the openemr mysql user
342 password=$(makepasswd --char=12)
344 # openemr installation VARIABLES
345 if [ "$MPASS" == "" ] ; then
346 rootpass="rootpass=BLANK" #MySQL server root password
347 else
348 rootpass="rootpass=$MPASS" #MySQL server root password
350 login="login=$INSTALL_USER" #username to MySQL openemr database
351 pass="pass=$password" #password to MySQL openemr database
352 dbname="dbname=$INSTALL_DATABASE" #MySQL openemr database name
355 # Run Auto Installer
357 sed -e 's@^exit;@ @' <$INST >$INSTTEMP
358 php -f $INSTTEMP $rootpass $login $pass $dbname >> $LOG 2>&1
359 rm -f $INSTTEMP
361 #remove global permission to all setup scripts
362 chmod 600 $OPENEMR/acl_setup.php
363 chmod 600 $OPENEMR/acl_upgrade.php
364 chmod 600 $OPENEMR/sl_convert.php
365 chmod 600 $OPENEMR/setup.php
366 chmod 600 $OPENEMR/sql_upgrade.php
367 chmod 600 $OPENEMR/ippf_upgrade.php
368 chmod 600 $OPENEMR/gacl/setup.php
370 log_only "Done configuring OpenEMR"
373 #This section configures Apache for OpenEMR
374 log_only "Configuring Apache for OpenEMR"
376 #Check to ensure the apache configuration files exists
377 if [ -f $APACHE ]; then
379 # First, backup the httpd.conf file before modifying
380 cp -f $APACHE $APACHE.BAK
382 # Second, append information to secure selected directories in OpenEMR
383 echo "#This is the start of the Apache configuration for OpenEMR." >> $APACHE
384 echo "#Below will secure directories with patient information." >> $APACHE
385 echo "<Directory \"$SITEDIR/documents\">" >> $APACHE
386 echo " order deny,allow" >> $APACHE
387 echo " Deny from all" >> $APACHE
388 echo "</Directory>" >> $APACHE
389 echo "<Directory \"$SITEDIR/edi\">" >> $APACHE
390 echo " order deny,allow" >> $APACHE
391 echo " Deny from all" >> $APACHE
392 echo "</Directory>" >> $APACHE
393 echo "<Directory \"$SITEDIR/era\">" >> $APACHE
394 echo " order deny,allow" >> $APACHE
395 echo " Deny from all" >> $APACHE
396 echo "</Directory>" >> $APACHE
397 echo "#This is the end of the Apache configuration for OpenEMR." >> $APACHE
399 #let user know the plan
400 prompt_input openemr/apache_configure high ret_result
401 log_only "Added entries to apache configuration to secure directories with patient information."
402 log_only "Placed backup of your original apache configuration file to $APACHE.BAK"
404 else
405 #can't find apache config file, so just echo instructions
406 log_only "We recommend placing below lines into your apache configuration file:"
407 log_only "#This is the start of the Apache configuration for OpenEMR."
408 log_only "#Below will secure directories with patient information."
409 log_only "<Directory \"$SITEDIR/documents\">"
410 log_only " order deny,allow"
411 log_only " Deny from all"
412 log_only "</Directory>"
413 log_only "<Directory \"$SITEDIR/edi\">"
414 log_only " order deny,allow"
415 log_only " Deny from all"
416 log_only "</Directory>"
417 log_only "<Directory \"$SITEDIR/era\">"
418 log_only " order deny,allow"
419 log_only " Deny from all"
420 log_only "</Directory>"
421 log_only "#This is the end of the Apache configuration for OpenEMR."
424 log_only "Done configuring Apache"
426 #This Section edits the php.ini file to accomodate the proper functioning of OpenEMR using php
427 log_only "Configuring PHP for OpenEMR"
429 #check to ensure the php configuration file exists
430 if [ -f $PHP ]; then
431 # First, collect php variables
432 collect_php () {
433 echo `grep -i "^[[:space:]]*$1[[:space:]=]" $PHP | cut -d \= -f 2 | cut -d \; -f 1 | sed 's/[ M]//gi'`
435 TAG_TEXT="short_open_tag"
436 TAG=$(collect_php "$TAG_TEXT")
437 EXEC_TEXT="max_execution_time"
438 EXEC=$(collect_php "$EXEC_TEXT")
439 INPUT_TEXT="max_input_time"
440 INPUT=$(collect_php "$INPUT_TEXT")
441 MEM_TEXT="memory_limit"
442 MEM=$(collect_php "$MEM_TEXT")
443 DISP_TEXT="display_errors"
444 DISP=$(collect_php "$DISP_TEXT")
445 LOGG_TEXT="log_errors"
446 LOGG=$(collect_php "$LOGG_TEXT")
447 GLOB_TEXT="register_globals"
448 GLOB=$(collect_php "$GLOB_TEXT")
449 POST_TEXT="post_max_size"
450 POST=$(collect_php "$POST_TEXT")
451 MAGIC_TEXT="magic_quotes_gpc"
452 MAGIC=$(collect_php "$MAGIC_TEXT")
453 UPLOAD_TEXT="file_uploads"
454 UPLOAD=$(collect_php "$UPLOAD_TEXT")
455 FILESIZE_TEXT="upload_max_filesize"
456 FILESIZE=$(collect_php "$FILESIZE_TEXT")
458 # Second, backup the php.ini file before modifying
459 cp $PHP $PHP.BAK
461 # Third, edit the required entries
462 # Do this in a for loop.
463 # First iteration will discover the recommended changes
464 # Second iteration will make the changes (if user request this)
465 FLAG_ON=0
466 process_php () {
467 if [ "$3" -eq "1" ]; then
468 # make rec to php.ini
469 if [ "$FLAG_ON" -eq "0" ]; then
470 log_only "We changed the following setting(s) in your php configuration file at $PHP :"
472 FLAG_ON=1
473 else
474 # modify php.ini
475 sed -i "s/^[ ]*$1[ =].*$/$1 = $2/" $PHP
476 log_only "Successfully set $1 = $2"
479 for i in `seq 1 2`; do
480 if [ "$TAG" != "On" ]; then
481 process_php "$TAG_TEXT" "On" $i
483 if [ "$EXEC" -lt "60" ]; then
484 process_php "$EXEC_TEXT" "60" $i
486 if [ "$INPUT" -lt "90" ]; then
487 process_php "$INPUT_TEXT" "90" $i
489 if [ "$MEM" -lt "128" ]; then
490 process_php "$MEM_TEXT" "128M" $i
492 if [ "$DISP" != "Off" ]; then
493 process_php "$DISP_TEXT" "Off" $i
495 if [ "$LOGG" != "On" ]; then
496 process_php "$LOGG_TEXT" "On" $i
498 if [ "$GLOB" != "Off" ]; then
499 process_php "$GLOB_TEXT" "Off" $i
501 if [ "$POST" -lt "30" ]; then
502 process_php "$POST_TEXT" "30M" $i
504 if [ "$MAGIC" != "On" ]; then
505 process_php "$MAGIC_TEXT" "On" $i
507 if [ "$UPLOAD" != "On" ]; then
508 process_php "$UPLOAD_TEXT" "On" $i
510 if [ "$FILESIZE" -lt "30" ]; then
511 process_php "$FILESIZE_TEXT" "30M" $i
513 if [ "$FLAG_ON" -eq "0" ]; then
514 log_only "Your PHP configuration is perfect for OpenEMR."
515 break
516 else
517 if [ "$i" -eq "1" ]; then
518 prompt_input openemr/php_configure high ret_result
521 if [ "$i" -eq "1" ]; then
522 log_only "(We have placed a backup of your php configuration at $PHP.BAK)"
524 done
525 else
526 #can't find php config file, so just echo instructions
527 log_only "We recommend ensuring you have below settings in your php configuration file:"
528 log_only "short_open_tag = On"
529 log_only "max_execution_time = 60"
530 log_only "max_input_time = 90"
531 log_only "memory_limit = 128M"
532 log_only "display_errors = Off"
533 log_only "log_errors = On"
534 log_only "register_globals = Off"
535 log_only "post_max_size = 30M"
536 log_only "magic_quotes_gpc = On"
537 log_only "file_uploads = On"
538 log_only "upload_max_filesize = 30M"
541 log_only "Done configuring PHP"
543 log_only "Restarting Apache service"
544 invoke-rc.d apache2 restart >> $LOG 2>&1
546 if $configure_flag; then
547 prompt_input openemr/success_install_config high ret_result
548 log_only "You can now use OpenEMR by browsing to:"
549 log_only "http://localhost/openemr"
550 log_only "user is 'admin' and password is 'pass'"
551 log_only "See the openemr man page for further instructions:"
552 log_only "type 'man openemr' at command line"
553 else
554 prompt_input openemr/success_install high ret_result
555 log_only "You can now configure OpenEMR by browsing to:"
556 log_only "http://localhost/openemr"
557 log_only "See the openemr man page for further instructions:"
558 log_only "type 'man openemr' at command line"
561 #update config file, change process to complete and remove plan and pass
562 sed -i "s/^[ ]*process[ =].*$/process=complete/" $CONFIG
563 sed -i "/^[ ]*plan[ =].*$/d" $CONFIG
565 #stop db
566 db_stop
568 exit 0
570 abort-upgrade|abort-remove|abort-deconfigure)
572 echo "postinst asked to do $1"
573 exit 0
576 echo "postinst called with unknown argument \`$1'" >&2
577 exit 1
579 esac
581 sleep 5
582 exit 0