Commits

Ian Bicking committed 418ace1

Added two experimental settings for scripts to run to help install non-standard projects

Comments (0)

Files changed (2)

silverlining/mgr-scripts/update-service.py

 def update_service(instance_name, clear=False):
     app_config = AppConfig.from_instance_name(instance_name)
     app_config.install_services(clear)
+    for script in app_config.package_install_script:
+        print 'Running install script %s' % script
+        run([script])
     packages = app_config.packages
     if packages:
         print 'Confirming packages installed: %s' % ', '.join(packages)
         os.makedirs(tmp)
     if not os.path.exists(app_config.log_dir):
         run(['sudo', '-u', 'www-data', 'mkdir', '-p', app_config.log_dir])
-
+    for script in app_config.after_install_script:
+        print 'Running post script %s' % script
+        run([script])
 
 if __name__ == '__main__':
     options, args = parser.parse_args()

silversupport/appconfig.py

         return self._parse_lines(self.config['production'].get('packages'))
 
     @property
+    def package_install_script(self):
+        """A list of scripts to call to install package stuff like apt
+        repositories"""
+        return self._parse_lines(
+            self.config['production'].get('package_install_script'),
+            relative_to=self.app_dir)
+
+    @property
+    def after_install_script(self):
+        """A list of scripts to call after installing packages"""
+        return self._parse_lines(
+            self.config['production'].get('after_install_script'),
+            relative_to=self.app_dir)
+
+    @property
     def config_required(self):
         return asbool(self.config['production'].get('config.required'))
 
             return None
         return os.path.join(self.app_dir, dir)
 
-    def _parse_lines(self, lines):
+    def _parse_lines(self, lines, relative_to=None):
         """Parse a configuration value into a series of lines,
         ignoring empty and comment lines"""
         if not lines:
             return []
-        return [
+        lines = [
             line.strip() for line in lines.splitlines()
             if line.strip() and not line.strip().startswith('#')]
+        if relative_to:
+            lines = [os.path.normpath(os.path.join(relative_to, line))
+                     for line in lines]
+        return lines
 
     def activate_services(self, environ=None):
         """Activates all the services for this application/configuration.