1
0
forked from ScoDoc/ScoDoc

modified to run as tools/script.sh

This commit is contained in:
IDK 2021-08-02 11:34:28 +03:00
parent 35d5d43eeb
commit 383fdb0e53
12 changed files with 97 additions and 65 deletions

View File

@ -11,11 +11,16 @@
set -eo pipefail
source config.sh
source utils.sh
# Le répertoire de ce script:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/config.sh"
source "$SCRIPT_DIR/utils.sh"
check_uid_root "$0"
cd "$SCRIPT_DIR"
usage() {
echo "$0 [-n DEPT]"
echo "(default to interactive mode)"

View File

@ -5,8 +5,12 @@
#
# $db_name is passed as an environment variable
source config.sh
source utils.sh
# Le répertoire de ce script:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/config.sh"
source "$SCRIPT_DIR/utils.sh"
check_uid_root "$0"

View File

@ -13,9 +13,11 @@
# E. Viennet, Sept 2008
#
# Le répertoire de ce script:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source config.sh
source utils.sh
source "$SCRIPT_DIR/config.sh"
source "$SCRIPT_DIR/utils.sh"
check_uid_root "$0"
usage() {

View File

@ -104,11 +104,11 @@ ps auxww > "$TMP"/ps.out
df -h > "$TMP"/df.out
dpkg -l > "$TMP"/dpkg.lst
(cd "$SCODOC_HOME"; git status > "$TMP"/git.status)
(cd "$SCODOC_HOME"; git diff > "$TMP"/git.diff)
(cd "$SCODOC_DIR"; git status > "$TMP"/git.status)
(cd "$SCODOC_DIR"; git diff > "$TMP"/git.diff)
(cd "$SCODOC_HOME"; git log -n 5 > "$TMP"/git.log)
ls -laR "$SCODOC_HOME" > "$TMP"/ls-laR
(cd "$SCODOC_DIR"; git log -n 5 > "$TMP"/git.log)
ls -laR "$SCODOC_DIR" > "$TMP"/ls-laR
# -------------------------------------

View File

@ -5,8 +5,11 @@
#
# $db_name and $DEPT passed as environment variables
source config.sh
source utils.sh
# Le répertoire de ce script:
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" ]
then

View File

@ -8,8 +8,11 @@
# Jun 2019, Oct 2019, Dec 2020, Jul 2021
#
source config.sh
source utils.sh
# Le répertoire de ce script:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/config.sh"
source "$SCRIPT_DIR/utils.sh"
check_uid_root "$0"

View File

@ -1,6 +1,7 @@
#!/bin/bash
# INUTILE
XXX
# Préparation d'une release ScoDoc
# Download last git

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@ -15,7 +15,7 @@ existing scodoc instances).
E. Viennet, june 2008, sept 2013
"""
from tools.scodocutils import *
from scodocutils import *
for dept in get_depts():
log("\nChecking database for dept %s" % dept)
@ -30,8 +30,6 @@ for dept in get_depts():
continue
cnx.set_session(autocommit=False)
cursor = cnx.cursor()
print "passing !"
continue
# Apply upgrades:
# SVN 564 -> 565
@ -1072,43 +1070,43 @@ for dept in get_depts():
# Base utilisateurs:
log("\nChecking users database")
cnx = psycopg2.connect(get_users_cnx_str())
cursor = cnx.cursor()
check_field(
cnx,
"sco_users",
"passwd_temp",
[
"alter table sco_users add column passwd_temp int default 0",
"update sco_users set passwd_temp=0",
],
)
check_field(
cnx,
"sco_users",
"status",
["alter table sco_users add column status text default NULL"],
)
check_field(
cnx,
"sco_users",
"date_expiration",
[
"alter table sco_users add column date_expiration date",
"update sco_users set status=NULL where status=''", # fix a bug in previous update...
],
)
check_field(
cnx,
"sco_users",
"login_edt",
[
"alter table sco_users add column login_edt text default NULL",
],
)
cnx.commit()
cnx.close()
log("\nNOT Checking users database")
# cnx = psycopg2.connect(get_users_cnx_str())
# cursor = cnx.cursor()
# check_field(
# cnx,
# "sco_users",
# "passwd_temp",
# [
# "alter table sco_users add column passwd_temp int default 0",
# "update sco_users set passwd_temp=0",
# ],
# )
# check_field(
# cnx,
# "sco_users",
# "status",
# ["alter table sco_users add column status text default NULL"],
# )
# check_field(
# cnx,
# "sco_users",
# "date_expiration",
# [
# "alter table sco_users add column date_expiration date",
# "update sco_users set status=NULL where status=''", # fix a bug in previous update...
# ],
# )
# check_field(
# cnx,
# "sco_users",
# "login_edt",
# [
# "alter table sco_users add column login_edt text default NULL",
# ],
# )
# cnx.commit()
# cnx.close()
# The end.
sys.exit(0)

View File

@ -9,8 +9,12 @@
# E. Viennet, Sept 2011, Nov 2013, Mar 2017, Aug 2020, Jul 2021
#
source config.sh
source utils.sh
# Le répertoire de ce script:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/config.sh"
source "$SCRIPT_DIR/utils.sh"
check_uid_root "$0"
# Safety check

View File

@ -8,8 +8,12 @@
#
# E. Viennet, Sept 2011, Aug 2020, Jul 2021
#
source config.sh
source utils.sh
# Le répertoire de ce script:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/config.sh"
source "$SCRIPT_DIR/utils.sh"
check_uid_root "$0"

View File

@ -2,15 +2,18 @@
"""
Some utilities used by upgrade scripts
XXX python2 XXX
"""
import glob
import os
import psycopg2
import sys
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):
@ -22,7 +25,7 @@ def log(msg):
def get_dept_cnx_str(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:
return open(f).readline().strip()
except:
@ -33,7 +36,7 @@ def get_dept_cnx_str(dept):
def get_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]

View File

@ -13,9 +13,14 @@
A REVOIR : utiliser releases
cd /opt/scodoc || { echo "Invalid directory"; exit 1; }
source config.sh
source utils.sh
# Le répertoire de ce script:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/config.sh"
source "$SCRIPT_DIR/utils.sh"
cd "$SCODOC_DIR" || { echo "Invalid directory"; exit 1; }
check_uid_root "$0"