Created
November 4, 2017 19:52
-
-
Save arcolife/f28762bbca4f008cf8abfe06b9d99b38 to your computer and use it in GitHub Desktop.
lib/backend/activate_dev_mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# $ . ./activate_dev_mode | |
# or | |
# $ source ./activate_dev_mode | |
# user_interrupt(){ | |
# echo -e "\n\nKeyboard Interrupt detected." | |
# exit | |
# } | |
# trap user_interrupt SIGINT | |
# trap user_interrupt SIGTSTP | |
cd ../../ | |
status=$(docker-compose ps | grep Up | wc -l) | |
if [[ $status -gt 6 ]]; then | |
echo "Attempting to kill web container.." | |
docker-compose kill web | |
elif [[ $status -lt 6 ]]; then | |
echo "Sarjitsu is not running. Setting up.." | |
docker-compose up -d | |
docker-compose kill web | |
fi | |
docker-compose ps | |
cd lib/backend/ | |
if [ ! -f conf/sar-index.cfg ]; then | |
echo ' | |
[ElasticSearch] | |
host = 0.0.0.0 | |
port = 9200 | |
[Settings] | |
index_prefix = sarjitsu | |
index_version = 1 | |
bulk_action_count = 2000 | |
number_of_shards = 5 | |
number_of_replicas = 1 | |
[Grafana] | |
dashboard_url = 0.0.0.0:3000 | |
api_url = http://0.0.0.0:5000/ | |
' > conf/sar-index.cfg | |
fi | |
# sed 's/DEBUG = False/DEBUG = True/g' src/config.py | |
# sed -i -e '/^DEBUG/ s/^#*/# /' src/config.py | |
# sed -i -e '/^CFG_PATH/ s/^#*/# /' src/config.py | |
echo 'DEBUG = True' > src/config_local.py | |
echo 'CFG_PATH = "'$(realpath conf/sar-index.cfg)'"' >> src/config_local.py | |
YUM_CMD=$(which yum) | |
APT_GET_CMD=$(which apt-get) | |
# OTHER_CMD=$(which <other installer>) | |
if [[ ! -z $YUM_CMD ]]; then | |
packages_count=$(rpm -q python3-devel gpgme-devel gpgme | wc -l) | |
if [[ ! $packages_count -eq 3 ]]; then | |
echo "Need sudo permission for installing python3 devel and gpgme/devel packages" | |
sudo dnf -y install python3-devel gpgme-devel gpgme | |
fi | |
elif [[ ! -z $APT_GET_CMD ]]; then | |
packages_status=$(dpkg -l libgpgme11 libgpgme11-dev python3-dev | grep 'no packages found') | |
if [[ ! -z $packages_status ]]; then | |
echo "Need sudo permission for installing python3 devel and gpgme/devel packages" | |
sudo apt-get install -y install libgpgme11 libgpgme11-dev python3-gpgme python3-dev | |
fi | |
else | |
echo "error can't install a few packages." | |
echo "kindly edit this script to add your package manager in 'OTHER_CMD='" | |
exit 1; | |
fi | |
host_status=$(grep '0.0.0.0 redis' /etc/hosts) | |
if [[ -z $host_status ]]; then | |
echo "Need sudo to append 0.0.0.0 -- redis to /etc/hosts" | |
echo '0.0.0.0 redis' | sudo tee -a /etc/hosts | |
fi | |
export VOS_CONFIG_PATH="$(realpath conf/sar-index.cfg)" | |
cd src/ | |
if [ ! -d venv/ ]; then | |
virtualenv -p python3 venv | |
source venv/bin/activate | |
pip install -r requirements.txt | |
fi | |
echo "Now run:" | |
echo "$ source venv/bin/activate && ./server.py" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment