Migrate from hg

This commit is contained in:
Oscar Alvarez 2020-04-15 09:19:30 -05:00
commit 96a8a6fa82
25 changed files with 7413 additions and 0 deletions

BIN
TEMPLATE50.dump Normal file

Binary file not shown.

29
backup_db.sh Normal file
View File

@ -0,0 +1,29 @@
#!/bin/sh
# Backup for databases Postgresql
# Crontab will execute everyday 2:10 a.m.
# Add next line to crontab /etc/crontab
# 10 2 * * * psk $HOME/.scripts/backup_db.sh
backup_dir=$HOME/.backups
DBLIST="
DEMO
"
today="$(date +%Y-%m-%d)"
yesterday="$(date +%Y-%m-%d -d 'yesterday')"
for DB in ${DBLIST}
do
filename=${DB}-${today}.dump
/usr/bin/pg_dump --format=c --no-owner -f $backup_dir/$filename $DB
yesterday_file=$backup_dir/${DB}-${yesterday}.dump
if [ -e $yesterday_file ]
then
echo "Removing old file... " ${yesterday_file}
#rm ${yesterday_file}
fi
done

21
bitclone.sh Normal file
View File

@ -0,0 +1,21 @@
#!/bin/sh
source ~/.virtualenvs/tryton50/bin/activate
# Define your function here
bitClone () {
echo "Cloning remote Presik repo from Bitbucket... $1"
cd source
hg clone https://hg@bitbucket.org/presik/trytonpsk_$1
cd trytonpsk_$1
python setup.py install
if [ ! -z $2 ]
then
echo "Updating database... $2"
trytond-admin -v -c ~/.trytond/trytond.conf -d $2 -u $1
fi
}
# Invoke your function
bitClone "$1" "$2"

264
create_virtualenv_next50.sh Normal file
View File

@ -0,0 +1,264 @@
#!/bin/sh
#---------------------------------------------------------
# Script Install Tryton for Home Intance
# --------------------------------------------------------
# Main functions/variables declaration
# Colors constants
NONE="$(tput sgr0)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="\n$(tput setaf 3)"
BLUE="\n$(tput setaf 4)"
message () {
# $1 : Message
# $2 : Color
# return : Message colorized
local NOW="[$(date +%H:%M:%S)] "
echo "${2}${NOW}${1}${NONE}"
}
echo '----------------------------------------------------------'
#read -p 'Introduce the tryton name user: ' nameuser
version='5.0'
max_version='5.1'
integer_version='50'
venv='tryton'${integer_version}
nameuser='psk'
file_bashrc=${HOME}'/.bashrc'
# Install new apt packages
sudo apt install python3-gi-cairo
sudo apt install python-suds
# Create Virtualenv
message "[INFO] Creating virtualenv... $venv " ${BLUE}
source_="\nalias workon='source ~/.virtualenvs/$venv/bin/activate'"
echo $source_ >> $file_bashrc
virtualenv -p /usr/bin/python3 ${HOME}/.virtualenvs/${venv}
message "[INFO] Done." ${YELLOW}
read -p "Was created virtualenv $venv? " response
message "[INFO] Your Virtualenv $venv is ready...!" ${YELLOW}
PYT_CMD=${HOME}/.virtualenvs/${venv}/bin/python3
# Install PIP packages
PIP_CMD=${HOME}/.virtualenvs/${venv}/bin/pip3
message "[INFO] Installing main PIP3 packages..." ${BLUE}
pippackages="
bcrypt
virtualenv
pytz
werkzeug
wrapt
polib
python-stdnum
jinja2
python-sql
zeep
psycopg2
psycopg2cffi
psk_numword
vobject
simpleeval
cached-property
relatorio
chardet
passlib
requests
python-magic
flask
flask_tryton
flask_cors
gunicorn
Werkzeug==0.15.1
psycopg2-binary
wheel
suds-py3
beautifulsoup4
sendgrid
"
for i in ${pippackages}
do
${PIP_CMD} install $i
done
tryton_modules="
trytond
country
party
currency
company
product
stock
account
account_product
account_invoice
account_invoice_history
account_statement
account_invoice_stock
account_asset
account_credit_limit
bank
account_payment
product_cost_fifo
product_cost_history
product_price_list
product_attribute
stock_forecast
stock_inventory_location
stock_product_location
stock_location_sequence
stock_product_location
purchase
purchase_request
purchase_requisition
production
stock_supply
stock_supply_day
stock_supply_forecast
sale
sale_supply
sale_opportunity
sale_price_list
sale_invoice_grouping
sale_credit_limit
analytic_account
analytic_invoice
analytic_purchase
analytic_sale
account_credit_limit
commission
commission_waiting
production_work
production_routing
timesheet
company_work_time
account_stock_anglo_saxon
account_stock_continental
project
sale_stock_quantity
"
message "[INFO] Installing official Tryton packages..." ${BLUE}
for i in ${tryton_modules}
do
${PIP_CMD} install "trytond_$i>=$version,<$max_version" --no-deps
done
message "[INFO] Done. " ${YELLOW}
message "[INFO] Installing psk Tryton packages..." ${BLUE}
modules="
account_co_pyme
account_col
account_exo
account_stock_latin
account_voucher
analytic_voucher
account_bank_statement
party_personal
company_department
reports
staff
staff_co
staff_event
staff_payroll
staff_payroll_co
staff_contracting
staff_access
staff_access_extratime
staff_payroll_access
crm
ims
invoice_report
account_invoice_update
staff_access_shield
product_onebarcode
company_timezone
company_location
account_invoice_discount
product_onebarcode
product_reference
product_image
sale_discount
sale_shop
sale_salesman
sale_pos
sale_cost
sale_goal
sale_pos_frontend
sale_contract
analytic_sale_contract
stock_duration
stock_product_cost
stock_shipment_barcode
purchase_report
purchase_suggested
party_card
maintenance
hotel
audiovisual
engineering
transport
staff_document
document
document_communication
document_collection
notification_document
product_asset_attribute
account_invoice_discount
party_reward_points
commission_global
account_invoice_discount_wizard
invoice_editable_line
purchase_editable_line
account_invoice_discount_wizard
invoice_editable_line
purchase_discount
analytic_payroll
electronic_invoice_co
analytic_report
staff_payroll_project
staff_project
invoice_project
dashboard
email
real_state
surveillance
"
for i in ${modules}
do
hg clone https://presik@bitbucket.org/presik/trytonpsk_$i
cd $i
${PYT_CMD} setup.py install
cd ..
done
message "[INFO] Done. " ${YELLOW}
# Changing owner of new virtualenv
message "[INFO] Changing owner of virtualenv... " ${BLUE}
chown $nameuser:$nameuser -R ${HOME}/.virtualenvs/
message "[INFO] Done." ${YELLOW}
#systemctl stop strytond.service
#systemctl disable strytond.service
# Enable:
#systemctl enable strytond.service
# Reboot

4
disable_db.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/sh
update pg_database set datallowconn=false where datname='DOCITRANS';

21
gitclone.sh Normal file
View File

@ -0,0 +1,21 @@
#!/bin/sh
source ~/.virtualenvs/tryton50/bin/activate
# Define your function here
bitClone () {
echo "Cloning remote Presik git repo from Bitbucket... $1"
cd source
git clone https://git@bitbucket.org/presik/trytonpsk-$1.git
cd trytonpsk_$1
python setup.py install
if [ ! -z $2 ]
then
echo "Updating database... $2"
trytond-admin -v -c ~/.trytond/trytond.conf -d $2 -u $1
fi
}
# Invoke your function
bitClone "$1" "$2"

125
install_pos.sh Normal file
View File

@ -0,0 +1,125 @@
#!/bin/sh
#---------------------------------------------------------
# Script Install Tryton POS Client
# --------------------------------------------------------
# Main functions/variables declaration
version='5.0'
dir_pos_app=$HOME/.pos_app
#Create directories for tryton environment
message "[INFO] Creating tryton target directories... " ${BLUE}
dir_config_tryton=$HOME/.tryton
mkdir $dir_config_tryton
chmod 755 -R ${dir_config_tryton}
chown $USER:$USER -R ${dir_config_tryton}
mkdir $dir_pos_app
# Install sudo apt packages
echo "[INFO] Installing main sudo apt packages..."
#sudo sudo apt update
#sudo sudo apt -y upgrade
sudo apt -y install python-setuptools
sudo apt -y install libusb-1.0-0
sudo apt -y install libusb-1.0-0-dev
sudo apt -y install python-dev libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev
sudo apt -y install libssl-dev libffi-dev
sudo apt -y install python-gtk2
sudo apt -y install python-pip
sudo apt -y install python3-pip
sudo apt -y install python3-pyqt5
sudo apt -y install python3-pyqt5.qtsvg
sudo apt -y install python3-pyqt5.qtsql
sudo apt -y install python3-dateutil
sudo apt -y install python3-pillow
sudo apt -y install python3-serial
sudo apt -y install python-pil
sudo apt -y install mercurial
sudo apt -y install python3-gi
sudo apt -y install python3-gi-cairo
echo "[INFO] Done."
# Add install sale pos module
echo "[INFO] Installing pip packages..."
sudo pip3 install pyusb
sudo pip3 install pillow
sudo pip3 install qrcode
sudo pip3 install paramiko
sudo pip3 install pyserial
sudo pip3 install neox
sudo pip3 install pyudev
echo "[INFO] Done."
message "[INFO] Installing Tryton Client..." ${BLUE}
sudo pip3 install tryton==5.0.15
message "[INFO] Done." ${YELLOW}
echo "[INFO] Installing escpos..."
hg clone https://bitbucket.org/presik/python_escpos
cd python_escpos
sudo python3 setup.py install
cd ..
echo "[INFO] Done."
echo "[INFO] Installing client POS..."
hg clone https://bitbucket.org/presik/presik_pos
mv presik_pos $dir_pos_app
chown -R $USER:$USER $dir_pos_app
pos_client_dir=$dir_pos_app/presik_pos
cp $pos_client_dir/config_pos.ini $dir_config_tryton
chown -R $USER:$USER $dir_config_tryton
chmod 755 -R $dir_config_tryton
echo "[INFO] Done."
echo "[INFO] Creating POS launcher..."
data_launcher="
[Desktop Entry]\n
Version=$version\n
Name=Caja POS\n
Comment=POS Client Tryton\n
Exec=python3 $pos_client_dir/pospro\n
Icon=$pos_client_dir/app/share/pos-icon.svg\n
Terminal=false\n
Type=Application\n
Categories=Utility;Application;\n
"
echo $data_launcher >> $HOME/Escritorio/cajapos.desktop
sudo chown $USER:$USER $HOME/Escritorio/cajapos.desktop
echo "[INFO] Done."
message "[INFO] Adding user target to lpadmin... " ${BLUE}
sudo usermod -a -G lp $USER
sudo usermod -a -G lpadmin $USER
sudo usermod -a -G dialout $USER
echo "[INFO] Done."
echo "[INFO] On Xubuntu removing apps no required..."
sudo apt -y purge parole gmusicbrowser pidgin gnome-sudoku gnome-mines thunderbird
sudo apt -y autoremove
echo "[INFO] Done."

59
install_predash.sh Normal file
View File

@ -0,0 +1,59 @@
#!/bin/sh
#---------------------------------------------------------
# Script Install Pedash
# --------------------------------------------------------
# Install apt-get packages
echo "[INFO] Installing main apt packages..."
#sudo apt-get update
#sudo apt-get -y upgrade
sudo apt -y install build-essential
sudo apt -y install python3-dev
echo "[INFO] Done."
echo "[INFO] Installing pip packages..."
sudo pip3 install simplejson
sudo pip3 install pycrypto
sudo pip3 install flask
sudo pip3 install flask_tryton
sudo pip3 install flask_cors
message "[INFO] Installing Predash WEB..." ${BLUE}
mkdir $HOME/.flask
mkdir $HOME/predash
cd $HOME/predash
hg clone https://bitbucket.org/presik/predash_web
cd predash_web && npm install && cd ..
echo "[INFO] Done."
message "[INFO] Installing Predash API..." ${BLUE}
hg clone https://bitbucket.org/presik/predash_api
cd predash_api && npm install && cd ..
echo "[INFO] Creating Config File..."
env_flask="
[General]
databases=['DEMO50']
host=0.0.0.0
trytond_config=/home/psk/.trytond/trytond.conf
[Auth]
api_key=xxxxxxxxxxxxxx
secret_key=xxxxxxxxxx
user=username
"
echo $env_flask >> $HOME/.flask/env_flask.ini
echo "[INFO] Done."

396
install_server_version_5.sh Normal file
View File

@ -0,0 +1,396 @@
#!/bin/sh
#---------------------------------------------------------
# Script Install Tryton for Home Intance
# --------------------------------------------------------
# Note: run this script with as user (not root), so doesn't use sudo for run it
# Main functions/variables declaration
# Colors constants
NONE="$(tput sgr0)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="\n$(tput setaf 3)"
BLUE="\n$(tput setaf 4)"
message () {
# $1 : Message
# $2 : Color
# return : Message colorized
local NOW="[$(date +%H:%M:%S)] "
echo "${2}${NOW}${1}${NONE}"
}
echo '----------------------------------------------------------'
#read -p 'Introduce the tryton name user: ' nameuser
version='5.0'
max_version='5.1'
integer_version='50'
venv='tryton'${integer_version}
nameuser=$SUDO_USER
HOME_USER=/home/psk
file_bashrc=$HOME_USER'/.bashrc'
PYT_CMD=$HOME_USER/.virtualenvs/${venv}/bin/python3
# apt get update
# Install PIP packages
PIP_CMD=$HOME_USER/.virtualenvs/${venv}/bin/pip3
source_="\nalias workon='source ~/.virtualenvs/$venv/bin/activate'"
export_="\nexport WORKON_HOME=$HOME_USER/.virtualenvs"
# Install apt-get packages
message "[INFO] Installing main apt-get packages..." ${BLUE}
appackages="
build-essential
python3-pip
python3-dev
python3-venv
python-gtk2
python-setuptools
postgresql
postgresql-server-dev-11
libffi-dev
libpq-dev
mercurial
libxml2-dev
libxslt-dev
python3-ldap
python3-dateutil
python3-lxml
python3-polib
python3-psycopg2
python3-genshi
python3-sql
python3-tz
python3-stdnum
python3-virtualenv
python3-simplejson
python3-pil
python3-magic
sqlite3
unoconv
virtualenv
libjansson4
python3-gi
python3-gi-cairo
gir1.2-goocanvas-2.0
gunicorn
"
for i in ${appackages}
do
sudo apt -y install $i
done
message "[INFO] Done." ${YELLOW}
# Create Virtualenv
message "[INFO] Creating virtualenv... $venv " ${BLUE}
echo $source_ >> $file_bashrc
echo $export_ >> $file_bashrc
virtualenv -p /usr/bin/python3 $HOME_USER/.virtualenvs/${venv}
message "[INFO] Done." ${YELLOW}
# Create db tryton user
#echo '----------------------------------------------------------'
#echo 'Now creating db tryton user...'
#passwd postgres
#su - postgres -c "createuser --superuser --password ${nameuser}"
#read -p "Introduce password for user created ${nameuser}: " pass
#sudo -u postgres psql -c "ALTER USER ${nameuser} WITH PASSWORD '${pass}'"
#message "[INFO] Done." ${YELLOW}
# Install PIP package
message "[INFO] Installing main PIP packages..." ${BLUE}
sudo pip install -U pip
sudo pip3 install -U pip
pippackages="
bcrypt
pytz
wrapt
polib
python-stdnum
jinja2
python-sql
psycopg2
psycopg2cffi
zeep
psk_numword
vobject
simpleeval
cached-property
relatorio
chardet
passlib
requests
psycopg2-binary
simplejson
pycrypto
flask
flask_tryton
flask_cors
Werkzeug==0.15.1
sendgrid
suds-py3
beautifulsoup4
qrcode
"
for i in ${pippackages}
do
${PIP_CMD} install $i
done
message "[INFO] Creating Predash directory and files..." ${BLUE}
mkdir $HOME_USER/.flask
mkdir $HOME_USER/.certificate
mkdir $HOME_USER/predash
hg clone https://hg@bitbucket.org/presik/predash_api
cp predash_api/dash.ini ~/.flask/dash.ini
sudo cp predash_api/predash_api.service /etc/systemd/system/predash_api.service
sudo chmod 755 /etc/systemd/system/predash_api.service
sudo systemctl enable predash_api.service
hg clone https://hg@bitbucket.org/presik/predash_web
sudo cp predash_web.service /etc/systemd/system/predash_web.service
sudo chmod 755 /etc/systemd/system/predash_web.service
sudo systemctl enable predash_web.service
message "[INFO] Done." ${YELLOW}
# Create directories for tryton environment
message "[INFO] Creating tryton target directories... " ${BLUE}
CONFIG_DIR="$HOME_USER/.trytond"
ATTACH_DIR="$HOME_USER/.attach"
BACKUP_DIR="$HOME_USER/.backups"
SCRIPTS_DIR="$HOME_USER/.scripts"
mkdir ${CONFIG_DIR}
chown -R ${nameuser}:${nameuser} ${CONFIG_DIR}
mkdir ${ATTACH_DIR}
chmod 755 ${ATTACH_DIR}
mkdir ${BACKUP_DIR}
chmod 755 ${BACKUP_DIR}
mkdir ${SCRIPTS_DIR}
chmod 755 ${SCRIPTS_DIR}
message "[INFO] Downloading install scripts... " ${BLUE}
#hg clone https://presik@bitbucket.org/presik/install_scripts
mv backup_db.sh $SCRIPTS_DIR
mv vacuum_db.sh $SCRIPTS_DIR
cp trytond.conf ${CONFIG_DIR}/trytond.conf
chmod 755 ${CONFIG_DIR}/trytond.conf
message "[INFO] Done." ${YELLOW}
tryton_modules="
trytond
trytond_country
trytond_party
trytond_currency
trytond_company
trytond_product
trytond_stock
trytond_account
trytond_account_product
trytond_account_invoice
trytond_account_invoice_history
trytond_account_statement
trytond_account_invoice_stock
trytond_account_asset
trytond_bank
trytond_account_payment
trytond_product_cost_fifo
trytond_product_cost_history
trytond_product_price_list
trytond_product_attribute
trytond_stock_forecast
trytond_stock_inventory_location
trytond_stock_product_location
trytond_stock_location_sequence
trytond_stock_product_location
trytond_purchase
trytond_purchase_request
trytond_purchase_requisition
trytond_purchase_shipment_cost
trytond_production
trytond_stock_supply
trytond_stock_supply_day
trytond_stock_supply_forecast
trytond_sale
trytond_sale_supply
trytond_sale_opportunity
trytond_sale_price_list
trytond_sale_invoice_grouping
trytond_sale_credit_limit
trytond_analytic_account
trytond_analytic_invoice
trytond_analytic_purchase
trytond_analytic_sale
trytond_account_credit_limit
trytond_commission
trytond_timesheet
trytond_company_work_time
trytond_project
trytond_carrier
"
message "[INFO] Installing official Tryton packages..." ${BLUE}
for i in ${tryton_modules}
do
${PIP_CMD} install "$i>=$version,<$max_version" --no-deps
done
message "[INFO] Done. " ${YELLOW}
# Install Presik modules
message "[INFO] Installing trytonpsk modules... " ${BLUE}
trytonpsk_modules="
trytonpsk_account_co_pyme
trytonpsk_account_col
trytonpsk_account_exo
trytonpsk_electronic_invoice_co
trytonpsk_account_voucher
trytonpsk_account_bank_statement
trytonpsk_party_personal
trytonpsk_company_department
trytonpsk_reports
trytonpsk_staff
trytonpsk_staff_co
trytonpsk_staff_event
trytonpsk_staff_payroll
trytonpsk_staff_payroll_co
trytonpsk_staff_contracting
trytonpsk_staff_access
trytonpsk_staff_access_extratime
trytonpsk_sale_goal
trytonpsk_invoice_report
trytonpsk_account_invoice_update
trytonpsk_company_timezone
trytonpsk_company_location
trytonpsk_stock_duration
trytonpsk_account_invoice_discount
trytonpsk_product_onebarcode
trytonpsk_product_reference
trytonpsk_product_image
trytonpsk_purchase_discount
trytonpsk_purchase_editable_ine
trytonpsk_sale_discount
trytonpsk_sale_shop
trytonpsk_sale_salesman
trytonpsk_sale_pos
trytonpsk_sale_cost
trytonpsk_sale_contract
trytonpsk_sale_pos_frontend
trytonpsk_purchase_report
trytonpsk_purchase_suggested
trytonpsk_purchase_editable_line
trytonpsk_account_invoice_discount
trytonpsk_party_reward_points
trytonpsk_email
trytonpsk_sms
trytonpsk_crm
trytonpsk_dashboard
"
for i in ${trytonpsk_modules}
do
hg clone https://presik@bitbucket.org/presik/$i
cd $i
${PYT_CMD} setup.py install
cd ..
done
message "[INFO] Done. " ${YELLOW}
# Copying initializing install server script
message "[INFO] Setting initializing trytond server... " ${BLUE}
DAEMON=$HOME_USER/.virtualenvs/${venv}/bin/trytond
SETTING='-c $HOME_USER/.trytond/trytond.conf'
init_cmd="su ${nameuser} -c '${DAEMON} ${SETTING}'"
# Changing owner of new virtualenv
message "[INFO] Changing owner of virtualenv... " ${BLUE}
chown $nameuser:$nameuser -R $HOME_USER/.virtualenvs/
message "[INFO] Done." ${YELLOW}
#Change permissions of /var/lib/trytond
message "[INFO] Changing permissions of /var/lib/trytond... " ${BLUE}
mkdir /var/lib/trytond
chown ${nameuser}:${nameuser} /var/lib/trytond
chmod -R 755 /var/lib/trytond
# Initializing server
sudo cp strytond.service /etc/systemd/system/strytond.service
sudo chmod 755 /etc/systemd/system/strytond.service
sudo cp strytond_service /usr/local/bin/strytond_service
sudo chmod 755 /usr/local/bin/strytond_service
sudo systemctl enable strytond.service
message "[INFO] Done." ${YELLOW}
message "[INFO] Starting trytond server... " ${BLUE}
sudo systemctl start strytond.service
message "[INFO] Ok." ${YELLOW}
sudo systemctl status strytond.service
message "[INFO] Adding optimization of postgresql... " ${BLUE}
message "[INFO] Ok." ${YELLOW}
# Creating new database
echo '----------------------------------------------------------'
read -p 'Introduce name for the new database: ' new_db
runuser -l psk -c "createdb $new_db"
echo "Database created sucessfully -----------------> " $new_db
echo '----------------------------------------------------------'
echo 'Restoring database... in ' $new_db
pg_restore -d $new_db TEMPLATE50.dump
message "[INFO] Adding script backup and maintenance of database... " ${BLUE}
sed -i "s/DEMO/${new_db}/g" backup_db.sh
cp backup_db.sh $HOME_USER/.scripts/backup_db.sh
chmod 755 $HOME_USER/.scripts/backup_db.sh
echo "10 8 * * * $SUDO_USER $HOME_USER/.scripts/backup_db.sh" > /etc/crontab
echo "[INFO] Done."
#TODO: Activate tryton log
message "[INFO] Activating Tryton log... " ${BLUE}
echo
message "[INFO] Your Tryton Server is ready...!" ${YELLOW}

42
mupdate.sh Normal file
View File

@ -0,0 +1,42 @@
#!/bin/sh
#--------------------------------------------------------------
# Script Automate Update Tryton Module
# -------------------------------------------------------------
nameuser='psk'
venv='tryton50'
dir_source=$HOME'/source/'
databases="
DEMO
"
modules="$@"
echo Number of arguments: $#
echo Arguments: ${modules}
souhome() {
workon $venv
echo Removing all under: ${dir_source}
rm -R ${dir_source}*
for module in ${modules}
do
hg clone https://presik@bitbucket.org/presik/trytonpsk_${module}
mv trytonpsk_${module} ${dir_source}
cd ${dir_source}trytonpsk_${module}
python setup.py install
done
for DB in ${databases}
do
echo "Database Target -----------------> " $DB
trytond-admin -v -c ~/.trytond/trytond.conf -d $DB -u ${module}
done
}
souhome
sudo systemctl restart strytond
cd ..

17
new_cloud.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/sh
# As root
apt update
apt upgrade
apt install -y build-essential
apt install -y postgresql
apt install -y git
apt autoremove
locale-gen en_US en_US.UTF-8
useradd -m psk
passwd psk
usermod -aG sudo,adm psk
sudo chsh -s /bin/bash psk
sudo reboot

11
patch_es_tryton.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
#--------------------------------------------------------------
# Script Automate Update Spanish Translation Stock
# -------------------------------------------------------------
cd patch_locale
cp stock_es.po /home/psk/.virtualenvs/tryton50/lib/python3.6/site-packages/trytond/modules/stock/locale/es.po
cp purchase_es.po /home/psk/.virtualenvs/tryton50/lib/python3.6/site-packages/trytond/modules/purchase/locale/es.po
cp sale_es.po /home/psk/.virtualenvs/tryton50/lib/python3.6/site-packages/trytond/modules/sale/locale/es.po

1349
patch_locale/purchase_es.po Normal file

File diff suppressed because it is too large Load Diff

2031
patch_locale/sale_es.po Normal file

File diff suppressed because it is too large Load Diff

2772
patch_locale/stock_es.po Normal file

File diff suppressed because it is too large Load Diff

15
predash_api.service Normal file
View File

@ -0,0 +1,15 @@
# Script Predash API Server Presik Technologies
[Unit]
Description=Predash API Server
After=network.target
[Service]
User=psk
WorkingDirectory=/home/psk/predash/predash_api
ExecStart=/home/psk/.virtualenvs/tryton50/bin/gunicorn -c gun_config.py wsgi:app
#ExecStop=
[Install]
WantedBy=multi-user.target

17
predash_web.service Normal file
View File

@ -0,0 +1,17 @@
# Script Server Presik Technologies
[Unit]
Description=Predash Web Server
[Service]
User=psk
Group=psk
ExecStart=/home/psk/predash/run_predash.sh
ExecStop=
Environment="REACT_APP_TRYTON_API_HOST=cloud2.presik.com"
Environment="REACT_APP_TRYTON_API_PORT=5000"
[Install]
WantedBy=multi-user.target

32
renew-certificate.sh Normal file
View File

@ -0,0 +1,32 @@
# Crontab will execute every month first day
# Add next line to crontab /etc/crontab
# 10 2 1 * * psk /home/psk/renew_certificate.sh
# First stop web server nginx
sudo systemctl stop nginx
# Execute renew
sudo /opt/letsencrypt/certbot-auto renew
# Remove local certificate
rm ~/.certificate/*
# Copy certificate from root path to user home path
sudo cp /etc/letsencrypt/live/cloud10.presik.com/fullchain.pem ~/.certificate
sudo cp /etc/letsencrypt/live/cloud10.presik.com/privkey.pem ~/.certificate
# Change permissions
sudo chown psk:psk ~/.certificate/*
# Restart nginx
sudo systemctl start nginx
# Check certificate expiration
openssl x509 -enddate -noout -in /home/psk/.certificate/fullchain.pem
sudo reboot

6
run_predash.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
source ~/.virtualenvs/tryton50/bin/activate
cd /home/psk/predash/predash-web && npm start

68
server_add_pos.sh Normal file
View File

@ -0,0 +1,68 @@
#!/bin/sh
#---------------------------------------------------------
# Script Install Tryton for Home Intance
# --------------------------------------------------------
# Main functions/variables declaration
# Colors constants
NONE="$(tput sgr0)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="\n$(tput setaf 3)"
BLUE="\n$(tput setaf 4)"
message () {
# $1 : Message
# $2 : Color
# return : Message colorized
local NOW="[$(date +%H:%M:%S)] "
echo "${2}${NOW}${1}${NONE}"
}
echo '----------------------------------------------------------'
#read -p 'Introduce the tryton name user: ' nameuser
version='5.0'
max_version='5.1'
major_version_client='5.0.7'
integer_version='50'
venv='tryton'${integer_version}
nameuser=$SUDO_USER
file_bashrc=$HOME'/.bashrc'
PYT_CMD=$HOME/.virtualenvs/${venv}/bin/python3
# Updating server with POS modules
message "[INFO] Setting initializing trytond server... " ${BLUE}
DAEMON=$HOME/.virtualenvs/${venv}/bin/trytond
SETTING='-c $HOME/.trytond/trytond.conf'
DB=$1
message "[INFO] Updating server with POS modules... " ${BLUE}
systemctl stop strytond.service
POS_MODULES="
sale_discount
sale_product_onebarcode
sale_goal
sale_salesman
sale_shop
sale_pos
sale_pos_frontend
"
for i in ${POS_MODULES}
do
su ${nameuser} -c ${DAEMON} ${SETTING} -d ${DB} -u ${i}
done
message "[INFO] Done. " ${YELLOW}
message "[INFO] Restarting trytond server... " ${BLUE}
systemctl start strytond.service
systemctl status strytond.service
message "[INFO] Ok." ${YELLOW}

11
strytond.service Normal file
View File

@ -0,0 +1,11 @@
# Script Tryton Server Presik Technologies
[Unit]
Description=Trytond Server
[Service]
ExecStart=/usr/local/bin/strytond_service start
ExecStop=/usr/local/bin/strytond_service stop
[Install]
WantedBy=multi-user.target

17
strytond_cron Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
# Author: Oscar Alvarez, 01/07/2016
NAME="strytond_cron"
DESC="Tryton Cron"
NAME_ENV="tryton50"
DAEMON="${HOME}/.virtualenvs/${NAME_ENV}/bin/trytond-cron"
PIDFILE="/var/run/$NAME.pid"
CONFIG="${HOME}/.trytond/trytond.conf"
OPTIONS="-c $CONFIG"
LOGOPTIONS="--logconf ${HOME}/.trytond/trytond_log.conf"
set -e
$DAEMON -v $OPTIONS -d MYDB

85
strytond_service Normal file
View File

@ -0,0 +1,85 @@
#!/bin/sh
# Author: Oscar Alvarez, 01/07/2016
NAME="strytond"
DESC="Tryton"
PSKUSER=psk
HOMEX=/home/${PSKUSER}
NAME_ENV=tryton50
VERSION="5.0"
DAEMON="${HOMEX}/.virtualenvs/${NAME_ENV}/bin/trytond"
PIDFILE="/var/run/$NAME.pid"
CONFIG="${HOMEX}/.trytond/trytond.conf"
OPTIONS="-c $CONFIG"
set -e
# Using the lsb functions to perform the operations.
. /lib/lsb/init-functions
# Exit if Tryton not installed
if [ ! -x "$DAEMON" ]; then
log_action_msg "$DESC: Could not find tryton executable. Exiting."
exit 2
fi
# Function to verify if trytond is already running
run_check() {
if [ -e /var/run/strytond.pid ]; then
status_of_proc -p /var/run/strytond.pid $DAEMON $NAME > /dev/null && RETVAL=0 || RETVAL="$?"
else
RETVAL="2"
fi
}
start_tryton() {
run_check
if [ $RETVAL = 0 ]; then
log_action_msg "$DESC: Already running with PID $(cat $PIDFILE). Aborting."
exit 2
else
log_daemon_msg "$DESC: Starting the server version ${VERSION}."
start-stop-daemon --start --pidfile /var/run/strytond.pid --make-pidfile --exec $DAEMON -v -- $OPTIONS
RETVAL=$?
log_end_msg
fi
}
stop_tryton() {
start-stop-daemon --stop --pidfile /var/run/strytond.pid
}
status_tryton() {
run_check
if [ $RETVAL = 0 ]; then
log_action_msg "$DESC: Currently running with PID $(cat /var/run/strytond.pid)."
else
log_action_msg "$DESC: Not currently running."
fi
exit $RETVAL
}
case "$1" in
start)
start_tryton
;;
stop)
stop_tryton
;;
restart)
stop_tryton && sleep 2 && start_tryton
;;
status)
status_tryton
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
exit 0

5
test.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
echo 'PROBANDO USUARIO > ' $SUDO_USER, $HOME
# sudo apt update

16
trytond.conf Normal file
View File

@ -0,0 +1,16 @@
[database]
uri = postgresql://myuser:mypassword@127.0.0.1:5432/
path = /var/lib/trytond/
language = es
retry = 5
list=False
[session]
timeout = 6000
super_pwd = tX8dxTBaVgJ/U
[web]
listen = *:8000
hostname = 127.0.0.1
root = /var/www/localhost/tryton