forked from ScoDoc/DocScoDoc
modified to run as tools/script.sh
This commit is contained in:
parent
35d5d43eeb
commit
383fdb0e53
@ -11,11 +11,16 @@
|
|||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
source config.sh
|
# Le répertoire de ce script:
|
||||||
source utils.sh
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
|
source "$SCRIPT_DIR/config.sh"
|
||||||
|
source "$SCRIPT_DIR/utils.sh"
|
||||||
|
|
||||||
check_uid_root "$0"
|
check_uid_root "$0"
|
||||||
|
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "$0 [-n DEPT]"
|
echo "$0 [-n DEPT]"
|
||||||
echo "(default to interactive mode)"
|
echo "(default to interactive mode)"
|
||||||
|
@ -5,8 +5,12 @@
|
|||||||
#
|
#
|
||||||
# $db_name is passed as an environment variable
|
# $db_name is passed as an environment variable
|
||||||
|
|
||||||
source config.sh
|
# Le répertoire de ce script:
|
||||||
source utils.sh
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
|
source "$SCRIPT_DIR/config.sh"
|
||||||
|
source "$SCRIPT_DIR/utils.sh"
|
||||||
|
|
||||||
|
|
||||||
check_uid_root "$0"
|
check_uid_root "$0"
|
||||||
|
|
||||||
|
@ -13,9 +13,11 @@
|
|||||||
# E. Viennet, Sept 2008
|
# E. Viennet, Sept 2008
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Le répertoire de ce script:
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
source config.sh
|
source "$SCRIPT_DIR/config.sh"
|
||||||
source utils.sh
|
source "$SCRIPT_DIR/utils.sh"
|
||||||
|
|
||||||
check_uid_root "$0"
|
check_uid_root "$0"
|
||||||
usage() {
|
usage() {
|
||||||
|
@ -104,11 +104,11 @@ ps auxww > "$TMP"/ps.out
|
|||||||
df -h > "$TMP"/df.out
|
df -h > "$TMP"/df.out
|
||||||
dpkg -l > "$TMP"/dpkg.lst
|
dpkg -l > "$TMP"/dpkg.lst
|
||||||
|
|
||||||
(cd "$SCODOC_HOME"; git status > "$TMP"/git.status)
|
(cd "$SCODOC_DIR"; git status > "$TMP"/git.status)
|
||||||
(cd "$SCODOC_HOME"; git diff > "$TMP"/git.diff)
|
(cd "$SCODOC_DIR"; git diff > "$TMP"/git.diff)
|
||||||
|
|
||||||
(cd "$SCODOC_HOME"; git log -n 5 > "$TMP"/git.log)
|
(cd "$SCODOC_DIR"; git log -n 5 > "$TMP"/git.log)
|
||||||
ls -laR "$SCODOC_HOME" > "$TMP"/ls-laR
|
ls -laR "$SCODOC_DIR" > "$TMP"/ls-laR
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
|
@ -5,8 +5,11 @@
|
|||||||
#
|
#
|
||||||
# $db_name and $DEPT passed as environment variables
|
# $db_name and $DEPT passed as environment variables
|
||||||
|
|
||||||
source config.sh
|
# Le répertoire de ce script:
|
||||||
source utils.sh
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
|
source "$SCRIPT_DIR/config.sh"
|
||||||
|
source "$SCRIPT_DIR/utils.sh"
|
||||||
|
|
||||||
if [ "$(id -nu)" != "$SCODOC_USER" ]
|
if [ "$(id -nu)" != "$SCODOC_USER" ]
|
||||||
then
|
then
|
||||||
|
@ -8,8 +8,11 @@
|
|||||||
# Jun 2019, Oct 2019, Dec 2020, Jul 2021
|
# Jun 2019, Oct 2019, Dec 2020, Jul 2021
|
||||||
#
|
#
|
||||||
|
|
||||||
source config.sh
|
# Le répertoire de ce script:
|
||||||
source utils.sh
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
|
source "$SCRIPT_DIR/config.sh"
|
||||||
|
source "$SCRIPT_DIR/utils.sh"
|
||||||
|
|
||||||
check_uid_root "$0"
|
check_uid_root "$0"
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# INUTILE
|
# INUTILE
|
||||||
|
XXX
|
||||||
|
|
||||||
# Préparation d'une release ScoDoc
|
# Préparation d'une release ScoDoc
|
||||||
# Download last git
|
# Download last git
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -15,7 +15,7 @@ existing scodoc instances).
|
|||||||
E. Viennet, june 2008, sept 2013
|
E. Viennet, june 2008, sept 2013
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from tools.scodocutils import *
|
from scodocutils import *
|
||||||
|
|
||||||
for dept in get_depts():
|
for dept in get_depts():
|
||||||
log("\nChecking database for dept %s" % dept)
|
log("\nChecking database for dept %s" % dept)
|
||||||
@ -30,8 +30,6 @@ for dept in get_depts():
|
|||||||
continue
|
continue
|
||||||
cnx.set_session(autocommit=False)
|
cnx.set_session(autocommit=False)
|
||||||
cursor = cnx.cursor()
|
cursor = cnx.cursor()
|
||||||
print "passing !"
|
|
||||||
continue
|
|
||||||
# Apply upgrades:
|
# Apply upgrades:
|
||||||
|
|
||||||
# SVN 564 -> 565
|
# SVN 564 -> 565
|
||||||
@ -1072,43 +1070,43 @@ for dept in get_depts():
|
|||||||
|
|
||||||
|
|
||||||
# Base utilisateurs:
|
# Base utilisateurs:
|
||||||
log("\nChecking users database")
|
log("\nNOT Checking users database")
|
||||||
cnx = psycopg2.connect(get_users_cnx_str())
|
# cnx = psycopg2.connect(get_users_cnx_str())
|
||||||
cursor = cnx.cursor()
|
# cursor = cnx.cursor()
|
||||||
check_field(
|
# check_field(
|
||||||
cnx,
|
# cnx,
|
||||||
"sco_users",
|
# "sco_users",
|
||||||
"passwd_temp",
|
# "passwd_temp",
|
||||||
[
|
# [
|
||||||
"alter table sco_users add column passwd_temp int default 0",
|
# "alter table sco_users add column passwd_temp int default 0",
|
||||||
"update sco_users set passwd_temp=0",
|
# "update sco_users set passwd_temp=0",
|
||||||
],
|
# ],
|
||||||
)
|
# )
|
||||||
check_field(
|
# check_field(
|
||||||
cnx,
|
# cnx,
|
||||||
"sco_users",
|
# "sco_users",
|
||||||
"status",
|
# "status",
|
||||||
["alter table sco_users add column status text default NULL"],
|
# ["alter table sco_users add column status text default NULL"],
|
||||||
)
|
# )
|
||||||
check_field(
|
# check_field(
|
||||||
cnx,
|
# cnx,
|
||||||
"sco_users",
|
# "sco_users",
|
||||||
"date_expiration",
|
# "date_expiration",
|
||||||
[
|
# [
|
||||||
"alter table sco_users add column date_expiration date",
|
# "alter table sco_users add column date_expiration date",
|
||||||
"update sco_users set status=NULL where status=''", # fix a bug in previous update...
|
# "update sco_users set status=NULL where status=''", # fix a bug in previous update...
|
||||||
],
|
# ],
|
||||||
)
|
# )
|
||||||
check_field(
|
# check_field(
|
||||||
cnx,
|
# cnx,
|
||||||
"sco_users",
|
# "sco_users",
|
||||||
"login_edt",
|
# "login_edt",
|
||||||
[
|
# [
|
||||||
"alter table sco_users add column login_edt text default NULL",
|
# "alter table sco_users add column login_edt text default NULL",
|
||||||
],
|
# ],
|
||||||
)
|
# )
|
||||||
cnx.commit()
|
# cnx.commit()
|
||||||
cnx.close()
|
# cnx.close()
|
||||||
|
|
||||||
# The end.
|
# The end.
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -9,8 +9,12 @@
|
|||||||
# E. Viennet, Sept 2011, Nov 2013, Mar 2017, Aug 2020, Jul 2021
|
# E. Viennet, Sept 2011, Nov 2013, Mar 2017, Aug 2020, Jul 2021
|
||||||
#
|
#
|
||||||
|
|
||||||
source config.sh
|
# Le répertoire de ce script:
|
||||||
source utils.sh
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
|
source "$SCRIPT_DIR/config.sh"
|
||||||
|
source "$SCRIPT_DIR/utils.sh"
|
||||||
|
|
||||||
check_uid_root "$0"
|
check_uid_root "$0"
|
||||||
|
|
||||||
# Safety check
|
# Safety check
|
||||||
|
@ -8,8 +8,12 @@
|
|||||||
#
|
#
|
||||||
# E. Viennet, Sept 2011, Aug 2020, Jul 2021
|
# E. Viennet, Sept 2011, Aug 2020, Jul 2021
|
||||||
#
|
#
|
||||||
source config.sh
|
# Le répertoire de ce script:
|
||||||
source utils.sh
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
|
source "$SCRIPT_DIR/config.sh"
|
||||||
|
source "$SCRIPT_DIR/utils.sh"
|
||||||
|
|
||||||
|
|
||||||
check_uid_root "$0"
|
check_uid_root "$0"
|
||||||
|
|
||||||
|
@ -2,15 +2,18 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
Some utilities used by upgrade scripts
|
Some utilities used by upgrade scripts
|
||||||
|
XXX python2 XXX
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import psycopg2
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from config import Config
|
SCODOC_DIR = os.environ.get("SCODOC_DIR", "/opt/scodoc")
|
||||||
|
SCODOC_VAR_DIR = os.environ.get("SCODOC_VAR_DIR", "/opt/scodoc-data")
|
||||||
|
|
||||||
|
|
||||||
def log(msg):
|
def log(msg):
|
||||||
@ -22,7 +25,7 @@ def log(msg):
|
|||||||
|
|
||||||
def get_dept_cnx_str(dept):
|
def get_dept_cnx_str(dept):
|
||||||
"db cnx string for dept"
|
"db cnx string for dept"
|
||||||
f = os.path.join(Config.SCODOC_VAR_DIR, "config", "depts", dept + ".cfg")
|
f = os.path.join(SCODOC_VAR_DIR, "config", "depts", dept + ".cfg")
|
||||||
try:
|
try:
|
||||||
return open(f).readline().strip()
|
return open(f).readline().strip()
|
||||||
except:
|
except:
|
||||||
@ -33,7 +36,7 @@ def get_dept_cnx_str(dept):
|
|||||||
|
|
||||||
def get_depts():
|
def get_depts():
|
||||||
"list of defined depts"
|
"list of defined depts"
|
||||||
files = glob.glob(Config.SCODOC_VAR_DIR + "/config/depts/*.cfg")
|
files = glob.glob(SCODOC_VAR_DIR + "/config/depts/*.cfg")
|
||||||
return [os.path.splitext(os.path.split(f)[1])[0] for f in files]
|
return [os.path.splitext(os.path.split(f)[1])[0] for f in files]
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,9 +13,14 @@
|
|||||||
|
|
||||||
A REVOIR : utiliser releases
|
A REVOIR : utiliser releases
|
||||||
|
|
||||||
cd /opt/scodoc || { echo "Invalid directory"; exit 1; }
|
# Le répertoire de ce script:
|
||||||
source config.sh
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
source utils.sh
|
|
||||||
|
source "$SCRIPT_DIR/config.sh"
|
||||||
|
source "$SCRIPT_DIR/utils.sh"
|
||||||
|
|
||||||
|
cd "$SCODOC_DIR" || { echo "Invalid directory"; exit 1; }
|
||||||
|
|
||||||
|
|
||||||
check_uid_root "$0"
|
check_uid_root "$0"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user