Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for RUN directory and LOG directory in setup.py.

Also makes the init script now work!
  • Loading branch information...
commit 185383a1700e59a4a51f53016f92f6d0dd37aeff 1 parent 528f078
@sduchesneau sduchesneau authored baloo committed
Showing with 49 additions and 17 deletions.
  1. +18 −14 bin/default/shinken.in
  2. +2 −0  setup.cfg
  3. +29 −3 setup.py
View
32 bin/default/shinken.in
@@ -1,6 +1,8 @@
# /etc/default/shinken
#$ETC$ is where we put all configuration files
-#$VAR$ is where we put all variables files (pid, and all)
+#$VAR$ is where we put some variables files (replaced by $RUN$ and $LOG$ for now)
+#$RUN$ is where we put pid files
+#$LOG$ is where we put log files
#$SCRIPTS_BIN$ is where the launch scripts will be send
@@ -8,6 +10,8 @@
ETC=$ETC$
VAR=$VAR$
BIN=$SCRIPTS_BIN$
+RUN=$RUN$
+LOG=$LOG$
###ARBITER PART
@@ -25,12 +29,12 @@ ARBITERDAEMON=$BIN/shinken-arbiter
#The ARBITER PID
if [ -r $SHINKENCFG ] ; then
tmppid=`grep 'lock_file=' $SHINKENCFG | grep -v '#' | tail -n 1 | awk -F '=' '{print $2}'`
- ARBITERPID=${tmppid-$VAR/arbiterd.pid}
+ ARBITERPID=${tmppid-$RUN/arbiterd.pid}
else
- ARBITERPID="$VAR/arbiterd.pid"
+ ARBITERPID="$RUN/arbiterd.pid"
fi
-ARBITERDEBUGFILE="$VAR/arbiter-debug.log"
+ARBITERDEBUGFILE="$LOG/arbiter-debug.log"
###SCHEDULER PART
@@ -41,9 +45,9 @@ SCHEDULERCFG="$ETC/schedulerd.ini"
SCHEDULERDAEMON=$BIN/shinken-scheduler
#The SCHEDULER PID
-SCHEDULERPID="$VAR/schedulerd.pid"
+SCHEDULERPID="$RUN/schedulerd.pid"
-SCHEDULERDEBUGFILE="$VAR/scheduler-debug.log"
+SCHEDULERDEBUGFILE="$LOG/scheduler-debug.log"
###POLLER PART
# location of the poller daemon configuration
@@ -53,9 +57,9 @@ POLLERCFG="$ETC/pollerd.ini"
POLLERDAEMON=$BIN/shinken-poller
#The poller pid
-POLLERPID="$VAR/pollerd.pid"
+POLLERPID="$RUN/pollerd.pid"
-POLLERDEBUGFILE="$VAR/poller-debug.log"
+POLLERDEBUGFILE="$LOG/poller-debug.log"
###REACTIONNER PART
@@ -66,9 +70,9 @@ REACTIONNERCFG="$ETC/reactionnerd.ini"
REACTIONNERDAEMON=$BIN/shinken-reactionner
#The reactionner pid
-REACTIONNERPID="$VAR/reactionnerd.pid"
+REACTIONNERPID="$RUN/reactionnerd.pid"
-REACTIONNERDEBUGFILE="$VAR/reactionner-debug.log"
+REACTIONNERDEBUGFILE="$LOG/reactionner-debug.log"
###BROKER PART
@@ -79,9 +83,9 @@ BROKERCFG="$ETC/brokerd.ini"
BROKERDAEMON=$BIN/shinken-broker
#The broker pid
-BROKERPID="$VAR/brokerd.pid"
+BROKERPID="$RUN/brokerd.pid"
-BROKERDEBUGFILE="$VAR/broker-debug.log"
+BROKERDEBUGFILE="$LOG/broker-debug.log"
###RECEIVER PART
@@ -92,9 +96,9 @@ RECEIVERCFG="$ETC/receiverd.ini"
RECEIVERDAEMON=$BIN/shinken-receiver
#The broker pid
-RECEIVERPID="$VAR/receiverd.pid"
+RECEIVERPID="$RUN/receiverd.pid"
-RECEIVERDEBUGFILE="$VAR/receiver-debug.log"
+RECEIVERDEBUGFILE="$LOG/receiver-debug.log"
# nicelevel to run nagios daemon with
View
2  setup.cfg
@@ -2,4 +2,6 @@
#sysconfigdir = /etc
etc-path=/etc/shinken
var-path=/var/lib/shinken
+run-path=/var/run/shinken
+log-path=/var/log/shinken
plugins-path=/usr/lib/nagios/plugins
View
32 setup.py
@@ -79,13 +79,15 @@ class install(_install):
user_options = _install.user_options + [
( 'etc-path=', None, 'read-only single-machine data' ),
( 'var-path=', None, 'modifiable single-machine data' ),
+ ( 'run-path=', None, 'PID files' ),
+ ( 'log-path=', None, 'LOG files' ),
( 'plugins-path=', None, 'program executables' ),
( 'owner=', None, (
- 'change owner for etc/* and var (default: %s)' % DEFAULT_OWNER
+ 'change owner for etc/*, var, run and log folders (default: %s)' % DEFAULT_OWNER
)
),
( 'group=', None, (
- 'change group for etc/* and var (default: %s)' % DEFAULT_GROUP
+ 'change group for etc/*, var, run and log folders (default: %s)' % DEFAULT_GROUP
)
),
]
@@ -94,6 +96,8 @@ def initialize_options(self):
_install.initialize_options(self)
self.etc_path = None
self.var_path = None
+ self.run_path = None
+ self.log_path = None
self.plugins_path = None
self.owner = None
self.group = None
@@ -104,6 +108,10 @@ def finalize_options(self):
self.etc_path = default_paths['etc']
if self.var_path is None:
self.var_path = default_paths['var']
+ if self.run_path is None:
+ self.run_path = default_paths['run']
+ if self.log_path is None:
+ self.log_path = default_paths['log']
if self.plugins_path is None:
self.plugins_path = default_paths['libexec']
if self.owner is None:
@@ -112,7 +120,7 @@ def finalize_options(self):
self.group = DEFAULT_GROUP
if self.root:
- for attr in ('etc_path', 'var_path', 'plugins_path'):
+ for attr in ('etc_path', 'var_path', 'plugins_path', 'run_path', 'log_path'):
setattr(self, attr, change_root(self.root, getattr(self, attr)))
@@ -128,6 +136,8 @@ def initialize_options (self):
self.build_base = None
self.etc_path = None
self.var_path = None
+ self.run_path = None
+ self.log_path = None
self.plugins_path = None
self._install_scripts = None
@@ -146,6 +156,8 @@ def finalize_options (self):
self.set_undefined_options('install_config',
('etc_path', 'etc_path'),
('var_path', 'var_path'),
+ ('run_path', 'run_path'),
+ ('log_path', 'log_path'),
('plugins_path', 'plugins_path'),
('owner', 'owner'),
('group', 'group')
@@ -176,6 +188,8 @@ def generate_default_shinken_file(self):
# substitute
buf = buf.replace("$ETC$", self.etc_path)
buf = buf.replace("$VAR$", self.var_path)
+ buf = buf.replace("$RUN$", self.run_path)
+ buf = buf.replace("$LOG$", self.log_path)
buf = buf.replace("$SCRIPTS_BIN$", self._install_scripts)
# write out the new file
f = open(outfile, "w")
@@ -261,6 +275,8 @@ def initialize_options(self):
self.root = None
self.etc_path = None # typically /etc on Posix systems
self.var_path = None # typically /var on Posix systems
+ self.run_path = None # typically /etc on Posix systems
+ self.log_path = None # typically /var on Posix systems
self.plugins_path = None # typically /libexec on Posix systems
def finalize_options(self):
@@ -273,6 +289,8 @@ def finalize_options(self):
('root', 'root'),
('etc_path', 'etc_path'),
('var_path', 'var_path'),
+ ('run_path', 'run_path'),
+ ('log_path', 'log_path'),
('plugins_path', 'plugins_path'),
('owner', 'owner'),
('group', 'group')
@@ -297,6 +315,8 @@ def run(self):
# recursivly changing permissions for etc/shinken and var/lib/shinken
self.recursive_chown(self.etc_path, uid, gid, self.owner, self.group)
self.recursive_chown(self.var_path, uid, gid, self.owner, self.group)
+ self.recursive_chown(self.run_path, uid, gid, self.owner, self.group)
+ self.recursive_chown(self.log_path, uid, gid, self.owner, self.group)
def get_inputs (self):
@@ -368,16 +388,22 @@ def update_file_with_string(infilename, outfilename, match, new_string):
if 'win' in sys.platform:
default_paths = {'var': "c:\\shinken\\var",
'etc': "c:\\shinken\\etc",
+ 'log': "c:\\shinken\\var",
+ 'run': "c:\\shinken\\var",
'libexec': "c:\\shinken\\libexec",
}
elif 'linux' in sys.platform:
default_paths = {'var': "/var/lib/shinken/",
'etc': "/etc/shinken",
+ 'run': "/var/run/shinken",
+ 'log': "/var/log/shinken",
'libexec': "/usr/lib/shinken/plugins",
}
elif 'bsd' in sys.platform or 'dragonfly' in sys.platform:
default_paths = {'var': "/var/lib/shinken",
'etc': "/usr/local/etc/shinken",
+ 'run': "/var/run/shinken",
+ 'log': "/var/log/shinken",
'libexec': "/usr/local/libexec/shinken",
}
else:
Please sign in to comment.
Something went wrong with that request. Please try again.