Skip to content
Snippets Groups Projects
Commit d338423f authored by David Schmitz's avatar David Schmitz
Browse files

update install-centos.sh runfod.sh to be more flexible regarding installation directory

parent ab5edf10
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,35 @@
# with Celery, Redis, and sqlite.
#
fod_dir="/srv/flowspy"
venv_dir="/srv/venv"
install_basesw=1
install_fodproper=1
if [ $# -ge 1 -a "$1" = "--both" ]; then
#
while [ $# -gt 0 ]; do
if [ $# -ge 1 -a "$1" = "--here" ]; then
shift 1
fod_dir="$PWD"
venv_dir="$PWD/venv"
elif [ $# -ge 1 -a "$1" = "--base_dir" ]; then
shift 1
base_dir="$1"
shift 1
fod_dir="$base_dir/flowspy"
venv_dir="$base_dir/venv"
elif [ $# -ge 1 -a "$1" = "--fod_dir" ]; then
shift 1
fod_dir="$1"
shift 1
elif [ $# -ge 1 -a "$1" = "--venv_dir" ]; then
shift 1
venv_dir="$1"
shift 1
elif [ $# -ge 1 -a "$1" = "--both" ]; then
shift 1
install_basesw=1
install_fodproper=1
......@@ -18,8 +44,31 @@ elif [ $# -ge 1 -a "$1" = "--fodproper" ]; then
shift 1
install_basesw=0
install_fodproper=1
else
break
fi
done
##
venv_dir_base="$(dirname "$venv_dir")"
static_dir="$fod_dir/static"
inst_dir="$(dirname "$0")"
mkdir -p "$fod_dir" || exit
if [ "$(stat -Lc "%i" "$inst_dir/" "$fod_dir/" | sort -n -k 1 -u | wc -l)" = "1" ]; then
inst_dir_is_fod_dir=1
else
inst_dir_is_fod_dir=0
fi
echo "$0: inst_dir=$inst_dir fod_dir=$fod_dir => inst_dir_is_fod_dir=$inst_dir_is_fod_dir venv_dir=$venv_dir static_dir=$static_dir" 1>&2
#exit
##
if [ "$install_basesw" = 1 ]; then
......@@ -50,8 +99,11 @@ fi
if [ "$install_fodproper" = 0 ]; then
echo "Setup partial python environment for FoD"
virtualenv-3 /srv/venv
source /srv/venv/bin/activate
#virtualenv-3 /srv/venv
virtualenv-3 "$venv_dir"
ln -sf "$venv_dir" "$fod_dir/venv"
#source /srv/venv/bin/activate
source "$venv_dir/bin/activate"
#fix for broken anyjson and cl
pip install 'setuptools<58'
......@@ -62,24 +114,32 @@ else
set -e
echo "Setup python environment for FoD"
mkdir -p /var/log/fod /srv
virtualenv-3 /srv/venv
mkdir -p /var/log/fod "$venv_dir_base"
#virtualenv-3 /srv/venv
virtualenv-3 "$venv_dir"
ln -sf "$venv_dir" "$fod_dir/venv"
(
set +e
source /srv/venv/bin/activate
mkdir -p /srv/flowspy/log/
#source /srv/venv/bin/activate
source "$venv_dir/bin/activate"
#mkdir -p /srv/flowspy/log/
mkdir -p "$fod_dir/log/"
# Select source dir and copy FoD into /srv/flowspy/
if [ "`basename "$0"`" = install-centos.sh ]; then
# this script is in the source directory
cp -f -r "`dirname $0`"/* /srv/flowspy/
#cp -f -r "`dirname $0`"/* /srv/flowspy/
cp -f -r "`dirname $0`"/* "$fod_dir"
elif [ -e /vagrant ]; then
# vagrant's copy in /vagrant/
cp -f -r /vagrant/* /srv/flowspy/
#cp -f -r /vagrant/* /srv/flowspy/
cp -f -r /vagrant/* "$fod_dir"
elif [ -e ./install-centos.sh ]; then
# current directory is with the sourcecode
cp -f -r ./* /srv/flowspy/
#cp -f -r ./* /srv/flowspy/
cp -f -r ./* "$fod_dir"
else
echo "Could not find FoD src directory tried `dirname $0`, /vagrant/, ./"
exit 1
......@@ -87,11 +147,14 @@ else
set -e
cd /srv/flowspy/
#cd /srv/flowspy/
cd "$fod_dir"
(
cd flowspy
cp -f settings.py.dist settings.py
patch settings.py < settings.py.patch
sed -i "s#/srv/flowspy#$fod_dir#" "settings.py"
)
pip install 'setuptools<58'
......@@ -100,10 +163,12 @@ else
touch flowspy/settings_local.py
#./manage.py syncdb --noinput
mkdir -p /srv/flowspy/static/
#mkdir -p /srv/flowspy/static/
mkdir -p "$static_dir"
./manage.py collectstatic --noinput
./manage.py migrate
./manage.py loaddata initial_data
sed -i "s#/srv/flowspy#$fod_dir#" "$fod_dir/supervisord.conf"
)
set +e
......
......
......@@ -8,7 +8,14 @@ export LC_ALL="C" # this will unfortunatelly break ./manage.py createsuperuser a
#venv_dir="/srv/venv"
fod_dir="$(dirname "$0")"
if [ -d "$fod_dir/venv" ]; then
venv_dir="$fod_dir/venv"
else
venv_dir="/srv/venv"
fi
##
echo "$0: ini fod_dir=$fod_dir venv_dir=$venv_dir" 1>&2
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment