[PATCH 1/3] Add /etc/sysconfig/imagefactory support

James Laska jlaska at redhat.com
Thu Dec 15 16:34:08 UTC 2011


---
 MANIFEST.in                 |    2 +-
 conf/imagefactory.sysconfig |   18 ++++++++++++++++++
 imagefactory.spec.in        |    2 ++
 scripts/imagefactory        |   30 +++++++++++++++++++-----------
 setup.py                    |    6 +++++-
 5 files changed, 45 insertions(+), 13 deletions(-)
 create mode 100644 conf/imagefactory.sysconfig

diff --git a/MANIFEST.in b/MANIFEST.in
index 14eeb65..15175f2 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1,2 @@
 include COPYING Documentation/man/imagefactory.1 cert-ec2.pem imagefactory.conf
-include scripts/imagefactory conf/*.conf
+include scripts/imagefactory conf/imagefactory.sysconfig conf/*.conf
diff --git a/conf/imagefactory.sysconfig b/conf/imagefactory.sysconfig
new file mode 100644
index 0000000..eff18af
--- /dev/null
+++ b/conf/imagefactory.sysconfig
@@ -0,0 +1,18 @@
+# Imagefactory configuration
+# http://aeolusproject.org
+
+# Default command-line options when starting imagefactory
+OPTIONS="--rest --debug"
+
+# Default log file for imagefactory (default: /var/log/imagefactory.log)
+#LOGFILE="/var/log/imagefactory.log"
+
+# Default lock file for imagefactory (default: /var/lock/subsys/imagefactory)
+#LOCKFILE="/var/lock/subsys/imagefactory"
+
+# Default process id file for imagefactory (default: /var/run/imagefactory.pid)
+#PIDFILE="/var/run/imagefactory.pid"
+
+# Default configuration file (default: /etc/imagefactory/imagefactory.conf)
+#CONFFILE="/etc/imagefactory/imagefactory.conf"
+
diff --git a/imagefactory.spec.in b/imagefactory.spec.in
index ca61f9e..43a6049 100644
--- a/imagefactory.spec.in
+++ b/imagefactory.spec.in
@@ -68,6 +68,7 @@ mkdir -p %{buildroot}/%{_localstatedir}/lib/imagefactory/images
 
 sed -i '/\/usr\/bin\/env python/d' %{buildroot}/%{python_sitelib}/imgfac/*.py
 
+cp conf/imagefactory.sysconfig %{buildroot}/%{_sysconfdir}/sysconfig/imagefactory
 cp conf/ec2_fedora_jeos_03_OCT_2011.conf %{buildroot}/%{_sysconfdir}/imagefactory/jeos_images
 cp conf/ec2_rhel_jeos_03_OCT_2011.conf %{buildroot}/%{_sysconfdir}/imagefactory/jeos_images
 
@@ -84,6 +85,7 @@ fi
 %doc COPYING
 %{_initddir}/imagefactory
 %config(noreplace) %{_sysconfdir}/imagefactory/imagefactory.conf
+%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
 %dir %attr(0755, root, root) %{_sysconfdir}/pki/imagefactory/
 %dir %attr(0755, root, root) %{_sysconfdir}/imagefactory/jeos_images/
 %dir %attr(0755, root, root) %{_localstatedir}/lib/imagefactory/images
diff --git a/scripts/imagefactory b/scripts/imagefactory
index 07c8847..48ca208 100755
--- a/scripts/imagefactory
+++ b/scripts/imagefactory
@@ -20,7 +20,6 @@
 # description: Image Factory tool
 #
 # processname: /usr/bin/imagefactory
-# pidfile: /var/run/imagefactory.pid
 
 ### BEGIN INIT INFO
 # Provides: imagefactory
@@ -37,16 +36,25 @@
 # source function library
 . /etc/init.d/functions
 
-
-OPTIONS="--rest --debug"
-if [ -e /etc/sysconfig/imagefactory ]; then
+if [ -r /etc/sysconfig/imagefactory ]; then
   . /etc/sysconfig/imagefactory
 fi
 
 RETVAL=0
 prog="imagefactory"
 binary=/usr/bin/imagefactory
-pidfile=/var/run/imagefactory.pid
+
+# You can overide these variables using /etc/sysconfig/deltacloud-core
+PIDFILE=${PIDFILE:-/var/run/$prog.pid}
+LOCKFILE=${LOCKFILE:-/var/lock/subsys/$prog}
+CONFFILE=${CONFFILE:-}
+OPTIONS=${OPTIONS:-}
+
+if [ -n "$CONFFILE" ]; then
+    OPTIONS="--config $CONFFILE $OPTIONS"
+fi
+
+# LOGFILE=${LOGFILE:-/var/log/$prog.log}
 
 start() {
         [ -x $binary ] || exit 5
@@ -55,9 +63,9 @@ start() {
                 RETVAL=1
                 failure
         else
-                daemon --pidfile=$pidfile $binary $OPTIONS
+                daemon --pidfile=$PIDFILE $binary $OPTIONS
                 RETVAL=$?
-                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/imagefactory
+                [ $RETVAL -eq 0 ] && touch $LOCKFILE
         fi;
         echo
         return $RETVAL
@@ -69,9 +77,9 @@ stop() {
                 RETVAL=1
                 failure
         else
-                killproc -p $pidfile $binary
+                killproc -p $PIDFILE $binary
                 RETVAL=$?
-                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/imagefactory
+                [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
         fi;
         echo
         return $RETVAL
@@ -79,7 +87,7 @@ stop() {
 
 #reload(){
 #        echo -n $"Reloading $prog: "
-#        killproc -p $pidfile $binary -HUP
+#        killproc -p $PIDFILE $binary -HUP
 #        RETVAL=$?
 #        echo
 #        return $RETVAL
@@ -91,7 +99,7 @@ restart(){
 }
 
 condrestart(){
-    [ -e /var/lock/subsys/imagefactory ] && restart
+    [ -e $LOCKFILE ] && restart
     return 0
 }
 
diff --git a/setup.py b/setup.py
index 015062b..4d05223 100644
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,11 @@ try:
 except Exception, e:
     raise RuntimeError("ERROR: version.txt could not be found.  Run 'git describe > version.txt' to get the correct version info.")
 
-datafiles=[('share/man/man1', ['Documentation/man/imagefactory.1']), ('/etc/imagefactory', ['imagefactory.conf']), ('/etc/pki/imagefactory', ['cert-ec2.pem']),    ('/etc/rc.d/init.d', ['scripts/imagefactory'])]
+datafiles=[('share/man/man1', ['Documentation/man/imagefactory.1']),
+           ('/etc/imagefactory', ['imagefactory.conf']),
+           ('/etc/pki/imagefactory', ['cert-ec2.pem']),
+           ('/etc/sysconfig', ['imagefactory']),
+           ('/etc/rc.d/init.d', ['scripts/imagefactory'])]
 
 class sdist(_sdist):
     """ custom sdist command to prepare imagefactory.spec file """
-- 
1.7.7.4




More information about the aeolus-devel mailing list