source: trunk/install.sh @ 8

Revision 8, 2.6 KB checked in by kay, 4 years ago (diff)

prompt Funktion überarbeitet

  • Property svn:executable set to *
  • Property svn:keywords set to Id Date Author Revision HeadURL URL
Line 
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
24preConfFileNames='addon_restartApache';
25preSuidAdministratorFileNames='addon_restartApache';
26preSuidCustomerFileNames='';
27preUninstallFileNames='addon_restartApache';
28copyDirs='addons www';
29
30prompt(){
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
51for 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
58done
59
60for dir in $copyDirs; do
61  if [ -d ./$dir ]; then
62    cp -R -p ./$dir/ /opt/pdadmin/;
63  fi
64done
65
66for 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
71done
72
73for 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
78done
79
80for 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
84done
85
86for 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
90done
Note: See TracBrowser for help on using the repository browser.