quoting stateDir path in case it includes spaces

This commit is contained in:
Aaron Andersen 2018-10-11 08:04:47 -04:00
parent 72635ba359
commit 975f476cd2

View File

@ -225,68 +225,68 @@ in
];
preStart = ''
# ensure cache directory exists for db:migrate command
mkdir -p ${cfg.stateDir}/cache
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/
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/
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/
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
ln -fs ${configurationYml} "${cfg.stateDir}/config/configuration.yml"
# link in all user specified themes
rm -rf ${cfg.stateDir}/public/themes/*
rm -rf "${cfg.stateDir}/public/themes/"*
for theme in ${concatStringsSep " " (mapAttrsToList unpackTheme cfg.themes)}; do
ln -fs $theme/* ${cfg.stateDir}/public/themes/
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/
ln -sf ${cfg.package}/share/redmine/public/themes.dist/* "${cfg.stateDir}/public/themes/"
# link in all user specified plugins
rm -rf ${cfg.stateDir}/plugins/*
rm -rf "${cfg.stateDir}/plugins/"*
for plugin in ${concatStringsSep " " (mapAttrsToList unpackPlugin cfg.plugins)}; do
ln -fs $plugin/* ${cfg.stateDir}/plugins/''${plugin##*-redmine-plugin-}
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}/
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
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
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}
chown -R ${cfg.user}:${cfg.group} "${cfg.stateDir}"
# execute redmine required commands prior to starting the application
@ -297,7 +297,7 @@ in
# 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 = {
@ -307,7 +307,7 @@ in
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";
ExecStart="${bundle} exec rails server webrick -e production -p ${toString cfg.port} -P '${cfg.stateDir}/redmine.pid'";
};
};