| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | # pdadmin_restartApache (pdadmin-Addon) |
|---|
| 4 | # Copyright (C) 2008 Kay Haeusler |
|---|
| 5 | # |
|---|
| 6 | # This program is free software: you can redistribute it and/or modify |
|---|
| 7 | # it under the terms of the GNU General Public License as published by |
|---|
| 8 | # the Free Software Foundation, either version 3 of the License, or |
|---|
| 9 | # (at your option) any later version. |
|---|
| 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, see <http://www.gnu.org/licenses/>. |
|---|
| 18 | |
|---|
| 19 | # $Author$ |
|---|
| 20 | # $Rev$ |
|---|
| 21 | # $Date$ |
|---|
| 22 | # $URL$ |
|---|
| 23 | |
|---|
| 24 | preConfFileNames='addon_restartApache'; |
|---|
| 25 | preSuidAdministratorFileNames='addon_restartApache'; |
|---|
| 26 | preSuidCustomerFileNames=''; |
|---|
| 27 | preUninstallFileNames='addon_restartApache'; |
|---|
| 28 | copyDirs='addons www'; |
|---|
| 29 | |
|---|
| 30 | prompt(){ |
|---|
| 31 | answer='' |
|---|
| 32 | while [ true ]; do |
|---|
| 33 | echo -n "${1} (${2})? [${3}] "; |
|---|
| 34 | read readAnswer |
|---|
| 35 | readAnswer=$(echo ${readAnswer} | tr [:upper:] [:lower:]); |
|---|
| 36 | |
|---|
| 37 | if [ "$readAnswer" == 'y' ] || [ "$readAnswer" == 'j' ] || [ "$readAnswer" == 'n' ]; then |
|---|
| 38 | answer=$readAnswer; |
|---|
| 39 | elif [ "$readAnswer" == '' ]; then |
|---|
| 40 | answer='${4}'; |
|---|
| 41 | else |
|---|
| 42 | answer=''; |
|---|
| 43 | fi |
|---|
| 44 | if [ "$answer" != '' ]; then |
|---|
| 45 | break; |
|---|
| 46 | fi |
|---|
| 47 | done |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | for conf in $preConfFileNames; do |
|---|
| 52 | if [ -f /opt/pdadmin/addons/conf/$conf.conf ]; then |
|---|
| 53 | prompt 'overwrite existing configuration' $conf.conf 'yN' 'n'; |
|---|
| 54 | if [ "$answer" == 'n' ]; then |
|---|
| 55 | cp -i -p /opt/pdadmin/addons/conf/$conf.conf /opt/pdadmin/addons/conf/$conf.conf.bak; |
|---|
| 56 | fi |
|---|
| 57 | fi |
|---|
| 58 | done |
|---|
| 59 | |
|---|
| 60 | for dir in $copyDirs; do |
|---|
| 61 | if [ -d ./$dir ]; then |
|---|
| 62 | cp -R -p ./$dir/ /opt/pdadmin/; |
|---|
| 63 | fi |
|---|
| 64 | done |
|---|
| 65 | |
|---|
| 66 | for suid in $preSuidAdministratorFileNames; do |
|---|
| 67 | if [ -f /opt/pdadmin/www/administrator/$suid.cgi ]; then |
|---|
| 68 | chown root:www /opt/pdadmin/www/administrator/$suid.cgi; |
|---|
| 69 | chmod 4750 /opt/pdadmin/www/administrator/$suid.cgi; |
|---|
| 70 | fi |
|---|
| 71 | done |
|---|
| 72 | |
|---|
| 73 | for suid in $preSuidCustomerFileNames; do |
|---|
| 74 | if [ -f /opt/pdadmin/www/customer/$suid.cgi ]; then |
|---|
| 75 | chown root:www /opt/pdadmin/www/customer/$suid.cgi; |
|---|
| 76 | chmod 4750 /opt/pdadmin/www/customer/$suid.cgi; |
|---|
| 77 | fi |
|---|
| 78 | done |
|---|
| 79 | |
|---|
| 80 | for uninstall in $preUninstallFileNames; do |
|---|
| 81 | if [ -f /opt/pdadmin/addons/share/$uninstall.uninstall.sh ]; then |
|---|
| 82 | chmod 0700 /opt/pdadmin/addons/share/$uninstall.uninstall.sh; |
|---|
| 83 | fi |
|---|
| 84 | done |
|---|
| 85 | |
|---|
| 86 | for conf in $preConfFileNames; do |
|---|
| 87 | if [ -f /opt/pdadmin/addons/conf/$conf.conf.bak ]; then |
|---|
| 88 | mv /opt/pdadmin/addons/conf/$conf.conf.bak /opt/pdadmin/addons/conf/$conf.conf; |
|---|
| 89 | fi |
|---|
| 90 | done |
|---|