anchor.diff:  
           # log files don't exist until after first command has been executed
           # correct ownership of files generated by calling exec rake ...
  -        chown -R ${cfg.user}:${cfg.group} ${cfg.stateDir}/log
  +        chown -R ${cfg.user}:${cfg.group} "${cfg.stateDir}/log"
         '';
   
         serviceConfig = {
  
positive.code:       ];
        preStart = ''
          # ensure cache directory exists for db:migrate command
          mkdir -p ${cfg.stateDir}/cache
  
          # create the basic directory layout the redmine package expects
          mkdir -p /run/redmine/public
  
          for i in config files log plugins tmp; do
            mkdir -p ${cfg.stateDir}/$i
            ln -fs ${cfg.stateDir}/$i /run/redmine/
          done
  
          for i in plugin_assets themes; do
            mkdir -p ${cfg.stateDir}/public/$i
            ln -fs ${cfg.stateDir}/public/$i /run/redmine/public/
          done
  
  
          # start with a fresh config directory
          # the config directory is copied instead of linked as some mutable data is stored in there
          rm -rf ${cfg.stateDir}/config/*
          cp -r ${cfg.package}/share/redmine/config.dist/* ${cfg.stateDir}/config/
  
          # link in the application configuration
          ln -fs ${configurationYml} ${cfg.stateDir}/config/configuration.yml
  
  
          # link in all user specified themes
          rm -rf ${cfg.stateDir}/public/themes/*
          for theme in ${concatStringsSep " " (mapAttrsToList unpackTheme cfg.themes)}; do
            ln -fs $theme/* ${cfg.stateDir}/public/themes/
          done
  
          # link in redmine provided themes
          ln -sf ${cfg.package}/share/redmine/public/themes.dist/* ${cfg.stateDir}/public/themes/
  
  
          # link in all user specified plugins
          rm -rf ${cfg.stateDir}/plugins/*
          for plugin in ${concatStringsSep " " (mapAttrsToList unpackPlugin cfg.plugins)}; do
            ln -fs $plugin/* ${cfg.stateDir}/plugins/''${plugin##*-redmine-plugin-}
          done
  
  
          # ensure correct permissions for most files
          chmod -R ug+rwX,o-rwx+x ${cfg.stateDir}/
  
  
          # handle database.passwordFile & permissions
          DBPASS=$(head -n1 ${cfg.database.passwordFile})
          cp -f ${databaseYml} ${cfg.stateDir}/config/database.yml
          sed -e "s,#dbpass#,$DBPASS,g" -i ${cfg.stateDir}/config/database.yml
          chmod 440 ${cfg.stateDir}/config/database.yml
  
  
          # generate a secret token if required
          if ! test -e "${cfg.stateDir}/config/initializers/secret_token.rb"; then
            ${bundle} exec rake generate_secret_token
            chmod 440 ${cfg.stateDir}/config/initializers/secret_token.rb
          fi
  
  
          # ensure everything is owned by ${cfg.user}
          chown -R ${cfg.user}:${cfg.group} ${cfg.stateDir}
  
  
          # execute redmine required commands prior to starting the application
  
negative.code:         Group = cfg.group;
          TimeoutSec = "300";
          WorkingDirectory = "${cfg.package}/share/redmine";
          ExecStart="${bundle} exec rails server webrick -e production -p ${toString cfg.port} -P '${cfg.stateDir}/redmine.pid'";
        };
  
      };
  