From d0f44ec5b54b29c2b18cdae8530611ef85ed6ea3 Mon Sep 17 00:00:00 2001 From: Erickson Silva Date: Mon, 7 Dec 2015 11:59:51 -0300 Subject: [PATCH] Adiciona script pra levantar automaticamente o servidor de tradução --- install/linux/install.sh | 68 -------------------------------------------------------------------- scripts/linux/autostart_server.sh | 14 ++++++++++++++ scripts/linux/install.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/linux/translation-server | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 68 deletions(-) delete mode 100755 install/linux/install.sh create mode 100755 scripts/linux/autostart_server.sh create mode 100755 scripts/linux/install.sh create mode 100755 scripts/linux/translation-server diff --git a/install/linux/install.sh b/install/linux/install.sh deleted file mode 100755 index a57129e..0000000 --- a/install/linux/install.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -read -r -p "Deseja fazer o download das dependências? [Y/n] " response - response=${response,,} # tolower - if [[ $response =~ ^(yes|y| ) ]]; then - mkdir ~/vlibras-libs - cd ~/vlibras-libs - - mkdir aelius - cd aelius - - wget 150.165.204.30:8080/translate/linux/aelius-install.tar.gz - - MACHINE_TYPE=`uname -m` - if [ ${MACHINE_TYPE} == 'x86_64' ]; then - wget 150.165.204.30:8080/translate/linux/hunpos/x86_64/hunpos-tag - else - wget 150.165.204.30:8080/translate/linux/hunpos/i386/hunpos-tag - fi - - read -r -p "Deseja instalar as dependências? [Y/n] " response - response=${response,,} # tolower - if [[ $response =~ ^(yes|y| ) ]]; then - echo -e "\n# Extraindo...\n" - tar -xf aelius-install.tar.gz -C . - mkdir bin - mv hunpos-tag bin/ - chmod 777 bin/hunpos-tag - - echo -e "# Instalando dependências...\n" - sudo apt-get update - sudo apt-get install -y python-dev python-setuptools python-pip python-yaml python-numpy python-matplotlib - sudo pip install nltk==3.0.5 nltk_tgrep --upgrade - - fi - - read -r -p "Deseja limpar os arquivos temporários? [Y/n] " response - response=${response,,} # tolower - if [[ $response =~ ^(yes|y| ) ]]; then - rm ~/vlibras-libs/aelius/aelius-install.tar.gz - fi - - fi - - -read -r -p "Deseja criar as variáveis de ambiente? [Y/n] " response - response=${response,,} # tolower - if [[ $response =~ ^(yes|y| ) ]]; then - # path to Hunpos Tag - echo -e "\nHUNPOS_TAGGER=\"$HOME/vlibras-libs/aelius/bin/hunpos-tag\"" >> ~/.bashrc - echo -e "export HUNPOS_TAGGER" >> ~/.bashrc - - # path to Aelius Data - echo -e "\nAELIUS_DATA=\"$HOME/vlibras-libs/aelius/aelius_data\"" >> ~/.bashrc - echo -e "export AELIUS_DATA" >> ~/.bashrc - - # path to NLTK Data - echo -e "\nNLTK_DATA=\"$HOME/vlibras-libs/aelius/nltk_data\"" >> ~/.bashrc - echo -e "export NLTK_DATA" >> ~/.bashrc - - # path to Aelius and Translate package (new version) - echo -e "\nPYTHONPATH=\"${PYTHONPATH}:$HOME/vlibras-libs/aelius:$HOME/vlibras-translate/src\"" >> ~/.bashrc - echo -e "export PYTHONPATH\n" >> ~/.bashrc - - echo -e "\n## Execute o seguinte comando para concluir:\n\n$ source ~/.bashrc\n" - fi - -echo -e "### Instalação finalizada!" diff --git a/scripts/linux/autostart_server.sh b/scripts/linux/autostart_server.sh new file mode 100755 index 0000000..64fca69 --- /dev/null +++ b/scripts/linux/autostart_server.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +read -r -p "Digite a porta para rodar o serviço: " response +response=${response,,} # tolower + +sudo cp translation-server /etc/init.d/ +cd /etc/init.d + +sudo sed -i 's/####!!!!/'$response'/g' translation-server +sudo chmod 755 translation-server +/etc/init.d/translation-server stop +sudo update-rc.d -f translation-server remove +sudo update-rc.d translation-server defaults +/etc/init.d/translation-server start \ No newline at end of file diff --git a/scripts/linux/install.sh b/scripts/linux/install.sh new file mode 100755 index 0000000..a2f6814 --- /dev/null +++ b/scripts/linux/install.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +read -r -p "Deseja fazer o download das dependências? [Y/n] " response + response=${response,,} # tolower + if [[ $response =~ ^(yes|y| ) ]]; then + mkdir ~/vlibras-libs + cd ~/vlibras-libs + + mkdir aelius + cd aelius + + wget 150.165.204.30:8080/translate/linux/aelius-install.tar.gz + + MACHINE_TYPE=`uname -m` + if [ ${MACHINE_TYPE} == 'x86_64' ]; then + wget 150.165.204.30:8080/translate/linux/hunpos/x86_64/hunpos-tag + else + wget 150.165.204.30:8080/translate/linux/hunpos/i386/hunpos-tag + fi + + read -r -p "Deseja instalar as dependências? [Y/n] " response + response=${response,,} # tolower + if [[ $response =~ ^(yes|y| ) ]]; then + echo -e "\n# Extraindo...\n" + tar -xf aelius-install.tar.gz -C . + mkdir bin + mv hunpos-tag bin/ + chmod 777 bin/hunpos-tag + + echo -e "# Instalando dependências...\n" + sudo apt-get update + sudo apt-get install -y python-dev python-setuptools python-pip python-flask python-yaml python-numpy python-matplotlib + sudo pip install nltk==3.0.5 nltk_tgrep --upgrade + + fi + + read -r -p "Deseja limpar os arquivos temporários? [Y/n] " response + response=${response,,} # tolower + if [[ $response =~ ^(yes|y| ) ]]; then + rm ~/vlibras-libs/aelius/aelius-install.tar.gz + fi + + fi + + +read -r -p "Deseja criar as variáveis de ambiente? [Y/n] " response + response=${response,,} # tolower + if [[ $response =~ ^(yes|y| ) ]]; then + # path to Hunpos Tag + echo -e "\nHUNPOS_TAGGER=\"$HOME/vlibras-libs/aelius/bin/hunpos-tag\"" >> ~/.bashrc + echo -e "export HUNPOS_TAGGER" >> ~/.bashrc + + # path to Aelius Data + echo -e "\nAELIUS_DATA=\"$HOME/vlibras-libs/aelius/aelius_data\"" >> ~/.bashrc + echo -e "export AELIUS_DATA" >> ~/.bashrc + + # path to NLTK Data + echo -e "\nNLTK_DATA=\"$HOME/vlibras-libs/aelius/nltk_data\"" >> ~/.bashrc + echo -e "export NLTK_DATA" >> ~/.bashrc + + # path to Aelius and Translate package (new version) + echo -e "\nPYTHONPATH=\"${PYTHONPATH}:$HOME/vlibras-libs/aelius:$HOME/vlibras-translate/src\"" >> ~/.bashrc + echo -e "export PYTHONPATH\n" >> ~/.bashrc + + echo -e "\n## Execute o seguinte comando para concluir:\n\n$ source ~/.bashrc\n" + fi + +echo -e "### Instalação finalizada!" diff --git a/scripts/linux/translation-server b/scripts/linux/translation-server new file mode 100755 index 0000000..830c4d0 --- /dev/null +++ b/scripts/linux/translation-server @@ -0,0 +1,93 @@ +#! /bin/sh +# /etc/init.d/translation-server + +dir="" +port=####!!!! +cmd="python -m TranslationServer "$port +user="" + +name=`basename $0` +pid_file="/var/tmp/run/$name.pid" +stdout_log="/var/tmp/log/$name.log" +stderr_log="/var/tmp/log/$name.err" + +mkdir -p /var/tmp/run /var/tmp/log + +get_pid() { + cat "$pid_file" +} + +is_running() { + [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1 +} + +case "$1" in + start) + if is_running; then + echo "Already started" + else + echo "Starting $name" + cd "$dir" + if [ -z "$user" ]; then + $cmd >> "$stdout_log" 2>> "$stderr_log" & + else + sudo -H -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" & + fi + echo $! > "$pid_file" + if ! is_running; then + echo "Unable to start, see $stdout_log and $stderr_log" + exit 1 + fi + fi + ;; + stop) + if is_running; then + echo -n "Stopping $name.." + kill `get_pid` + for i in {1..10} + do + if ! is_running; then + break + fi + + echo -n "." + sleep 1 + done + echo + + if is_running; then + echo "Not stopped; may still be shutting down or shutdown may have failed" + exit 1 + else + echo "Stopped" + if [ -f "$pid_file" ]; then + rm "$pid_file" + fi + fi + else + echo "Not running" + fi + ;; + restart) + $0 stop + if is_running; then + echo "Unable to stop, will not attempt to start" + exit 1 + fi + $0 start + ;; + status) + if is_running; then + echo "Running" + else + echo "Stopped" + exit 1 + fi + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +exit 0 \ No newline at end of file -- libgit2 0.21.2