root/HelpIM3_chi/helpim_setup.sh

Revision 626, 3.8 kB (checked in by winfried, 3 years ago)

- adding recycle of 2 hours to avoid closing connections by mysql
- updating setup scripts and README

  • Property svn:executable set to *
Line 
1#!/bin/sh
2
3# Configs
4BINTARGETFILE="/usr/local/bin/helpim"
5SHARETARGETPATH="/usr/local/share/HelpIM"
6CONFTARGETPATH="/etc/HelpIM"
7LOGPATH="/var/log/HelpIM"
8HELPIMUSER="helpim"
9HELPIMGROUP="helpim"
10WWWUSER="www-data"
11ADMINGROUP="adm"
12
13# Do these automaticly change them if needed
14SCRIPTTARGETPATH=`python -c "import sys; [(a[:11] == '/usr/local/' and a[-14:] == '/site-packages' and sys.stdout.write(a+'\n')) for a in sys.path]"`
15SOURCEPATH=`dirname "$0"`
16
17# copy python scripts and compile them
18echo "Copying python scripts to $SCRIPTTARGETPATH"
19if ! cp -r "$SOURCEPATH/HelpIM" "$SCRIPTTARGETPATH"; then
20  echo "Error while copying python scripts, aborting"
21  exit 1
22fi
23if ! chmod 755 "$SCRIPTTARGETPATH/HelpIM/bot/bot.py"; then
24  echo "Error while setting rights on $SCRIPTTARGETPATH/HelpIM/bot/bot.py, aborting"
25  exit 1
26fi
27echo "Precompiling $SCRIPTTARGETPATH/HelpIM"
28if ! python -c "import compileall; compileall.compile_dir('$SCRIPTTARGETPATH/HelpIM', force=True, quiet=True)"; then
29  echo "Error while compiling, aborting"
30  exit 1
31fi
32
33# htdocs to share
34echo "Copying resources to $SHARETARGETPATH"
35if [ ! -d "$SHARETARGETPATH" ]; then
36  if ! mkdir "$SHARETARGETPATH"; then
37    echo "Can't find or create $SHARETARGETPATH, aborting"
38    exit 1
39  fi
40fi
41if ! cp -r "$SOURCEPATH/htdocs" "$SHARETARGETPATH"; then
42  echo "Error while copying resources to $SHARETARGETPATH/htdocs, aborting"
43  exit 1
44fi
45
46# make user helpim
47if [ -z `id -un $HELPIMUSER` ]; then
48  echo "Creating helpim user: $HELPIMUSER (group: $HELPIMGROUP)"
49  addgroup --system $HELPIMGROUP
50  adduser --system --ingroup $HELPIMGROUP --no-create-home --disabled-password $HELPIMUSER
51  # make apache member of helpim group
52  if ! usermod -a -G $HELPIMGROUP $WWWUSER; then
53    echo "Error while adding $WWWUSER to $HELPIMGROUP, aborting"
54    exit 1
55  fi
56fi
57
58# config to /etc
59if [ ! -d "$CONFTARGETPATH" ]; then
60  echo "Creating configs in $CONFTARGETPATH"
61  if ! mkdir "$CONFTARGETPATH"; then
62    echo "Can't find or create $CONFTARGETPATH, aborting"
63    exit 1
64  fi
65  if ! cp "$SOURCEPATH/config/config.xml" "$CONFTARGETPATH"; then
66    echo "Error while copying config to $CONFTARGETPATH/htdocs, aborting"
67    exit 1
68  fi
69  if ! cp -r "$SOURCEPATH/config/sites" "$CONFTARGETPATH"; then
70    echo "Can not create $CONFTARGETPATH/sites, aborting"
71    exit 1
72  fi
73  # set rights to /etc/HelpIM/sites strict: the db passwords are in there
74  if ! chmod 750 "$CONFTARGETPATH/sites"; then
75    echo "Can not set rights of $CONFTARGETPATH/sites, aborting"
76    exit 1
77  fi
78  if ! chmod 640 "$CONFTARGETPATH/sites/localhost.xml"; then
79    echo "Can not set rights of $CONFTARGETPATH/sites/localhost.xml, aborting"
80    exit 1
81  fi
82  if ! chown -R root:$HELPIMGROUP "$CONFTARGETPATH/sites"; then
83    echo "Can not change ownership if $CONFTARGETPATH/sites, aborting"
84    exit 1
85  fi
86fi
87
88# make /var/log/HelpIM
89if [ ! -d "$LOGPATH" ]; then
90  echo "Creating $LOGPATH"
91  if ! mkdir "$LOGPATH"; then
92    echo "Can't find or create $LOGPATH, aborting"
93    exit 1
94  fi
95  if ! chown $HELPIMUSER:$ADMINGROUP "$LOGPATH"; then
96    echo "Can not change ownership if $LOGPATH, aborting"
97    exit 1
98  fi
99fi
100
101# make /usr/local/bin/helpim/HelpIM/bot/bot.py executable
102if ! chmod +x "$SCRIPTTARGETPATH/HelpIM/bot/bot.py"; then
103  echo "Error while making $SCRIPTTARGETPATH/HelpIM/bot/bot.py executable"
104  exit 1
105fi
106
107# link /usr/local/bin/helpim to HelpIM/bot/bot.py
108if [ ! -f "$BINTARGETFILE" ]; then
109  if ! ln -s "$SCRIPTTARGETPATH/HelpIM/bot/bot.py" "$BINTARGETFILE"; then
110    echo "Error while linking $BINTARGETFILE, aborting"
111    exit 1
112  fi
113fi
114
115# startup script naar /etc/init.d/
116if [ ! -f "/etc/init.d/helpim" ]; then
117  if ! cp "$SOURCEPATH/helpim_init.d" "/etc/init.d/helpim"; then
118    echo "Error while creating, /etc/init.d/helpim, aborting"
119    exit 1
120  fi
121  update-rc.d helpim defaults 85 05
122fi
Note: See TracBrowser for help on using the browser.