This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""Script to bootstrap an Odoo database (8.0).""" | |
import odoorpc | |
# Odoo connection | |
SUPER_PWD = 'admin' | |
HOST = 'localhost' | |
PORT = 8069 | |
DB = 'my_db' |
This file contains 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
# Copyrights https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ " |
This file contains 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 | |
# Vacuum, analyze and re-index all non-template postgres databases | |
# Should be run as root to avoid any permissions issues | |
db_list_sql="SELECT datname FROM pg_database WHERE NOT datistemplate AND datallowconn ORDER BY datname" | |
for db in $(su - postgres -c "psql -At -c '$db_list_sql'"); do | |
su - postgres -c "vacuumdb --analyze --quiet $db" | |
su - postgres -c "PGOPTIONS='--client-min-messages=warning' reindexdb --quiet $db" |
This file contains 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
# dump all databases once every 24 hours | |
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz | |
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night) | |
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze" | |
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet" | |
# re-index all databases once a week | |
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"' |
This file contains 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 | |
################################################################################ | |
# | |
# Script for Installation: ODOO v8 server on Ubuntu 14.04 LTS | |
# Author: André Schenkels, ICTSTUDIO 2014 | |
# | |
# Forked: n / master | |
#------------------------------------------------------------------------------- | |
# | |
# This script will install ODOO v8 Server on a clean Ubuntu 14.04 Server and: |
This file contains 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
# Courtesy: credativ UK | |
[DEFAULT] | |
addpath = echo "${MR_REPO}" >&0 | |
relink = mkdir -p "$(dirname "${MR_CONFIG}")"/server-addons; ln -sf "$(mr -c "${MR_CONFIG}" -q addpath <&1)"/* "$(dirname "${MR_CONFIG}")"/server-addons/ | |
[odoo] | |
checkout = git clone -b 11.0 https://github.com/odoo/odoo.git | |
addpath = echo "${MR_REPO}"/addons >&0 |
This file contains 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
;; database name = connect string | |
;; | |
;; connect string params: | |
;; dbname= host= port= user= password= | |
;; client_encoding= datestyle= timezone= | |
;; pool_size= connect_query= | |
[databases] | |
odoo1 = host=127.0.0.1 auth_user=odoo dbname=odoo1 port=5432 | |
odoo2 = host=127.0.0.1 auth_user=odoo dbname=odoo2 port=5432 | |
odoo3 = host=127.0.0.1 auth_user=odoo port=5432 dbname=odoo3 |
This file contains 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
-- Completely unused indexes: | |
SELECT relid::regclass as table, indexrelid::regclass as index | |
, pg_size_pretty(pg_relation_size(indexrelid)) | |
FROM pg_stat_user_indexes | |
JOIN pg_index | |
USING (indexrelid) | |
WHERE idx_scan = 0 | |
AND indisunique IS FALSE order by pg_relation_size(indexrelid); |
This file contains 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
SELECT pg_terminate_backend(pg_stat_activity.pid) | |
FROM pg_stat_activity | |
WHERE pg_stat_activity.datname = 'TARGET_DB' | |
AND pid <> pg_backend_pid(); |
This file contains 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
#/usr/bin/python3 | |
""" Demonstration of logging feature for a Flask App. """ | |
from logging.handlers import RotatingFileHandler | |
from flask import Flask, request, jsonify | |
from time import strftime | |
__author__ = "@ivanleoncz" | |
import logging |
OlderNewer