1 #!/usr/bin/rc -p 2 # ===================================================================== 3 # db-offline: set the database off-line, for maintenance. 4 # 5 # Copyright (c) 2007,2009 Carlo Strozzi 6 # 7 # This program is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; version 2 dated June, 1991. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program; if not, write to the Free Software 18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 # 20 # ===================================================================== 21 22 # ===================================================================== 23 # Program initialization 24 # ===================================================================== 25 26 CSA_PGM = ($CSA_PGM `{basename $0}) 27 if (~ $CSA ()) { 28 echo $CSA_PGM($#CSA_PGM)^:' $CSA not set, cannot continue' >[1=2] 29 exit 1 30 } 31 32 . $CSA || exit 1 33 34 # Even if $CSA exists and parses correctly it may not be what I expect. 35 # So the purpose of the first csaPrintMsg() is twofold: it tells that 36 # the program has started and causes it to exit if the function is 37 # undefined. 38 39 csaPrintMsg 0060 $CSA_PGM($#CSA_PGM) || exit $status 40 41 # ===================================================================== 42 # Local variables and functions 43 # ===================================================================== 44 45 # NONE 46 47 # ===================================================================== 48 # Main program 49 # ===================================================================== 50 51 # Stop the whole database (unless already stopped because of errors, 52 # or the CSA will already have blocked us much earlier than here). 53 54 csaLock $CSA_ROOT/var/csa-db-repair || csaExit.fault 55 56 touch $CSA_ROOT/var/csa-db-stopped || csaExit.fault 0003 touch 57 58 csaExit.ok # mandatory ! 59 60 # End of program.