fixed potential problem re-running install script

This commit is contained in:
tigerbot 2017-06-15 11:48:53 -06:00
parent 5158f4a4ec
commit dc226f8531
1 changed files with 21 additions and 12 deletions

View File

@ -81,6 +81,25 @@ detect_http_bin
## END HTTP_GET ## ## END HTTP_GET ##
mvdir_backward_compat()
{
old_dir=$1
new_dir=$2
# The symlink has already been set up, so no need to do anything.
if [ -L $old_dir ] && [ $(readlink $old_dir) == "$new_dir" ]; then
return 0
fi
if [ -d $old_dir ]; then
if [ $(ls $old_dir | wc -l) -gt 0 ]; then
mv /srv/walnut/packages/client-api-grants/* /srv/walnut/etc/client-api-grants/
fi
rm -r /srv/walnut/packages/client-api-grants
#rmdir /srv/walnut/packages/client-api-grants
fi
ln -snf $new_dir $old_dir
}
################### ###################
# # # #
@ -235,18 +254,8 @@ install_my_app()
mkdir -p /srv/walnut/packages/{rest,api,pages,services} mkdir -p /srv/walnut/packages/{rest,api,pages,services}
# backwards compat # backwards compat
if [ -d /srv/walnut/packages/client-api-grants ]; then mvdir_backward_compat /srv/walnut/packages/client-api-grants /srv/walnut/etc/client-api-grants
mv /srv/walnut/packages/client-api-grants/* /srv/walnut/etc/client-api-grants/ mvdir_backward_compat /srv/walnut/packages/sites /srv/walnut/var/sites
rm -r /srv/walnut/packages/client-api-grants
#rmdir /srv/walnut/packages/client-api-grants
fi
if [ -d /srv/walnut/packages/sites ]; then
mv /srv/walnut/packages/sites/* /srv/walnut/var/sites
rm -r /srv/walnut/packages/sites
#rmdir /srv/walnut/packages/sites
fi
ln -s /srv/walnut/etc/client-api-grants /srv/walnut/packages/client-api-grants
ln -s /srv/walnut/var/sites /srv/walnut/packages/client-api-grants
pushd /srv/walnut/core pushd /srv/walnut/core
/opt/walnut/bin/npm install /opt/walnut/bin/npm install