Commit d0f44ec5b54b29c2b18cdae8530611ef85ed6ea3

Authored by Erickson Silva
1 parent f608f9db
Exists in master and in 1 other branch devel

Adiciona script pra levantar automaticamente o servidor de tradução

install/linux/install.sh
@@ -1,68 +0,0 @@ @@ -1,68 +0,0 @@
1 -#!/bin/bash  
2 -  
3 -read -r -p "Deseja fazer o download das dependências? [Y/n] " response  
4 - response=${response,,} # tolower  
5 - if [[ $response =~ ^(yes|y| ) ]]; then  
6 - mkdir ~/vlibras-libs  
7 - cd ~/vlibras-libs  
8 -  
9 - mkdir aelius  
10 - cd aelius  
11 -  
12 - wget 150.165.204.30:8080/translate/linux/aelius-install.tar.gz  
13 -  
14 - MACHINE_TYPE=`uname -m`  
15 - if [ ${MACHINE_TYPE} == 'x86_64' ]; then  
16 - wget 150.165.204.30:8080/translate/linux/hunpos/x86_64/hunpos-tag  
17 - else  
18 - wget 150.165.204.30:8080/translate/linux/hunpos/i386/hunpos-tag  
19 - fi  
20 -  
21 - read -r -p "Deseja instalar as dependências? [Y/n] " response  
22 - response=${response,,} # tolower  
23 - if [[ $response =~ ^(yes|y| ) ]]; then  
24 - echo -e "\n# Extraindo...\n"  
25 - tar -xf aelius-install.tar.gz -C .  
26 - mkdir bin  
27 - mv hunpos-tag bin/  
28 - chmod 777 bin/hunpos-tag  
29 -  
30 - echo -e "# Instalando dependências...\n"  
31 - sudo apt-get update  
32 - sudo apt-get install -y python-dev python-setuptools python-pip python-yaml python-numpy python-matplotlib  
33 - sudo pip install nltk==3.0.5 nltk_tgrep --upgrade  
34 -  
35 - fi  
36 -  
37 - read -r -p "Deseja limpar os arquivos temporários? [Y/n] " response  
38 - response=${response,,} # tolower  
39 - if [[ $response =~ ^(yes|y| ) ]]; then  
40 - rm ~/vlibras-libs/aelius/aelius-install.tar.gz  
41 - fi  
42 -  
43 - fi  
44 -  
45 -  
46 -read -r -p "Deseja criar as variáveis de ambiente? [Y/n] " response  
47 - response=${response,,} # tolower  
48 - if [[ $response =~ ^(yes|y| ) ]]; then  
49 - # path to Hunpos Tag  
50 - echo -e "\nHUNPOS_TAGGER=\"$HOME/vlibras-libs/aelius/bin/hunpos-tag\"" >> ~/.bashrc  
51 - echo -e "export HUNPOS_TAGGER" >> ~/.bashrc  
52 -  
53 - # path to Aelius Data  
54 - echo -e "\nAELIUS_DATA=\"$HOME/vlibras-libs/aelius/aelius_data\"" >> ~/.bashrc  
55 - echo -e "export AELIUS_DATA" >> ~/.bashrc  
56 -  
57 - # path to NLTK Data  
58 - echo -e "\nNLTK_DATA=\"$HOME/vlibras-libs/aelius/nltk_data\"" >> ~/.bashrc  
59 - echo -e "export NLTK_DATA" >> ~/.bashrc  
60 -  
61 - # path to Aelius and Translate package (new version)  
62 - echo -e "\nPYTHONPATH=\"${PYTHONPATH}:$HOME/vlibras-libs/aelius:$HOME/vlibras-translate/src\"" >> ~/.bashrc  
63 - echo -e "export PYTHONPATH\n" >> ~/.bashrc  
64 -  
65 - echo -e "\n## Execute o seguinte comando para concluir:\n\n$ source ~/.bashrc\n"  
66 - fi  
67 -  
68 -echo -e "### Instalação finalizada!"  
scripts/linux/autostart_server.sh 0 → 100755
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +#!/bin/bash
  2 +
  3 +read -r -p "Digite a porta para rodar o serviço: " response
  4 +response=${response,,} # tolower
  5 +
  6 +sudo cp translation-server /etc/init.d/
  7 +cd /etc/init.d
  8 +
  9 +sudo sed -i 's/####!!!!/'$response'/g' translation-server
  10 +sudo chmod 755 translation-server
  11 +/etc/init.d/translation-server stop
  12 +sudo update-rc.d -f translation-server remove
  13 +sudo update-rc.d translation-server defaults
  14 +/etc/init.d/translation-server start
0 \ No newline at end of file 15 \ No newline at end of file
scripts/linux/install.sh 0 → 100755
@@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
  1 +#!/bin/bash
  2 +
  3 +read -r -p "Deseja fazer o download das dependências? [Y/n] " response
  4 + response=${response,,} # tolower
  5 + if [[ $response =~ ^(yes|y| ) ]]; then
  6 + mkdir ~/vlibras-libs
  7 + cd ~/vlibras-libs
  8 +
  9 + mkdir aelius
  10 + cd aelius
  11 +
  12 + wget 150.165.204.30:8080/translate/linux/aelius-install.tar.gz
  13 +
  14 + MACHINE_TYPE=`uname -m`
  15 + if [ ${MACHINE_TYPE} == 'x86_64' ]; then
  16 + wget 150.165.204.30:8080/translate/linux/hunpos/x86_64/hunpos-tag
  17 + else
  18 + wget 150.165.204.30:8080/translate/linux/hunpos/i386/hunpos-tag
  19 + fi
  20 +
  21 + read -r -p "Deseja instalar as dependências? [Y/n] " response
  22 + response=${response,,} # tolower
  23 + if [[ $response =~ ^(yes|y| ) ]]; then
  24 + echo -e "\n# Extraindo...\n"
  25 + tar -xf aelius-install.tar.gz -C .
  26 + mkdir bin
  27 + mv hunpos-tag bin/
  28 + chmod 777 bin/hunpos-tag
  29 +
  30 + echo -e "# Instalando dependências...\n"
  31 + sudo apt-get update
  32 + sudo apt-get install -y python-dev python-setuptools python-pip python-flask python-yaml python-numpy python-matplotlib
  33 + sudo pip install nltk==3.0.5 nltk_tgrep --upgrade
  34 +
  35 + fi
  36 +
  37 + read -r -p "Deseja limpar os arquivos temporários? [Y/n] " response
  38 + response=${response,,} # tolower
  39 + if [[ $response =~ ^(yes|y| ) ]]; then
  40 + rm ~/vlibras-libs/aelius/aelius-install.tar.gz
  41 + fi
  42 +
  43 + fi
  44 +
  45 +
  46 +read -r -p "Deseja criar as variáveis de ambiente? [Y/n] " response
  47 + response=${response,,} # tolower
  48 + if [[ $response =~ ^(yes|y| ) ]]; then
  49 + # path to Hunpos Tag
  50 + echo -e "\nHUNPOS_TAGGER=\"$HOME/vlibras-libs/aelius/bin/hunpos-tag\"" >> ~/.bashrc
  51 + echo -e "export HUNPOS_TAGGER" >> ~/.bashrc
  52 +
  53 + # path to Aelius Data
  54 + echo -e "\nAELIUS_DATA=\"$HOME/vlibras-libs/aelius/aelius_data\"" >> ~/.bashrc
  55 + echo -e "export AELIUS_DATA" >> ~/.bashrc
  56 +
  57 + # path to NLTK Data
  58 + echo -e "\nNLTK_DATA=\"$HOME/vlibras-libs/aelius/nltk_data\"" >> ~/.bashrc
  59 + echo -e "export NLTK_DATA" >> ~/.bashrc
  60 +
  61 + # path to Aelius and Translate package (new version)
  62 + echo -e "\nPYTHONPATH=\"${PYTHONPATH}:$HOME/vlibras-libs/aelius:$HOME/vlibras-translate/src\"" >> ~/.bashrc
  63 + echo -e "export PYTHONPATH\n" >> ~/.bashrc
  64 +
  65 + echo -e "\n## Execute o seguinte comando para concluir:\n\n$ source ~/.bashrc\n"
  66 + fi
  67 +
  68 +echo -e "### Instalação finalizada!"
scripts/linux/translation-server 0 → 100755
@@ -0,0 +1,93 @@ @@ -0,0 +1,93 @@
  1 +#! /bin/sh
  2 +# /etc/init.d/translation-server
  3 +
  4 +dir=""
  5 +port=####!!!!
  6 +cmd="python -m TranslationServer "$port
  7 +user=""
  8 +
  9 +name=`basename $0`
  10 +pid_file="/var/tmp/run/$name.pid"
  11 +stdout_log="/var/tmp/log/$name.log"
  12 +stderr_log="/var/tmp/log/$name.err"
  13 +
  14 +mkdir -p /var/tmp/run /var/tmp/log
  15 +
  16 +get_pid() {
  17 + cat "$pid_file"
  18 +}
  19 +
  20 +is_running() {
  21 + [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
  22 +}
  23 +
  24 +case "$1" in
  25 + start)
  26 + if is_running; then
  27 + echo "Already started"
  28 + else
  29 + echo "Starting $name"
  30 + cd "$dir"
  31 + if [ -z "$user" ]; then
  32 + $cmd >> "$stdout_log" 2>> "$stderr_log" &
  33 + else
  34 + sudo -H -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
  35 + fi
  36 + echo $! > "$pid_file"
  37 + if ! is_running; then
  38 + echo "Unable to start, see $stdout_log and $stderr_log"
  39 + exit 1
  40 + fi
  41 + fi
  42 + ;;
  43 + stop)
  44 + if is_running; then
  45 + echo -n "Stopping $name.."
  46 + kill `get_pid`
  47 + for i in {1..10}
  48 + do
  49 + if ! is_running; then
  50 + break
  51 + fi
  52 +
  53 + echo -n "."
  54 + sleep 1
  55 + done
  56 + echo
  57 +
  58 + if is_running; then
  59 + echo "Not stopped; may still be shutting down or shutdown may have failed"
  60 + exit 1
  61 + else
  62 + echo "Stopped"
  63 + if [ -f "$pid_file" ]; then
  64 + rm "$pid_file"
  65 + fi
  66 + fi
  67 + else
  68 + echo "Not running"
  69 + fi
  70 + ;;
  71 + restart)
  72 + $0 stop
  73 + if is_running; then
  74 + echo "Unable to stop, will not attempt to start"
  75 + exit 1
  76 + fi
  77 + $0 start
  78 + ;;
  79 + status)
  80 + if is_running; then
  81 + echo "Running"
  82 + else
  83 + echo "Stopped"
  84 + exit 1
  85 + fi
  86 + ;;
  87 + *)
  88 + echo "Usage: $0 {start|stop|restart|status}"
  89 + exit 1
  90 + ;;
  91 +esac
  92 +
  93 +exit 0
0 \ No newline at end of file 94 \ No newline at end of file