goldilocks.js/installer/install-system-service.sh

38 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2017-11-07 00:00:25 +00:00
safe_copy_config()
{
src=$1
dst=$2
2017-11-07 00:30:14 +00:00
$sudo_cmd mkdir -p $(dirname "$dst")
2017-11-07 00:00:25 +00:00
if [ -f "$dst" ]; then
2017-11-07 00:43:36 +00:00
$sudo_cmd rsync -a "$src" "$dst.latest"
2017-11-07 00:00:25 +00:00
# TODO edit config file with $my_user and $my_group
if [ "$(cat $dst)" == "$(cat $dst.latest)" ]; then
$sudo_cmd rm $dst.latest
else
echo "MANUAL INTERVENTION REQUIRED: check the systemd script update and manually decide what you want to do"
echo "diff $dst $dst.latest"
$sudo_cmd chown -R root:root "$dst.latest"
fi
else
2017-11-07 00:43:36 +00:00
$sudo_cmd rsync -a --ignore-existing "$src" "$dst"
2017-11-07 00:00:25 +00:00
fi
$sudo_cmd chown -R root:root "$dst"
$sudo_cmd chmod 644 "$dst"
}
installable=""
if [ -d "$my_root/etc/systemd/system" ]; then
2017-11-07 00:30:14 +00:00
source ./installer/install-for-systemd.sh
2017-11-07 00:00:25 +00:00
installable="true"
fi
if [ -d "/Library/LaunchDaemons" ]; then
2017-11-07 00:30:14 +00:00
source ./installer/install-for-launchd.sh
2017-11-07 00:00:25 +00:00
installable="true"
fi
if [ -z "$installable" ]; then
echo ""
echo "Unknown system service init type. You must install as a system service manually."
echo '(please file a bug with the output of "uname -a")'
echo ""
fi