2021-08-24 17:35:39 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Préparation d'une release ScoDoc:
|
|
|
|
die() {
|
|
|
|
echo; echo "Erreur: $1"; echo
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
PACKAGE_NAME=scodoc9
|
2021-08-25 22:56:36 +02:00
|
|
|
RELEASE_TAG=9.0.1
|
2021-08-24 17:35:39 +02:00
|
|
|
VERSION=9.0.0
|
|
|
|
RELEASE=1
|
|
|
|
ARCH="amd64"
|
|
|
|
FACTORY_DIR="/opt/factory"
|
|
|
|
DEST_DIR="$PACKAGE_NAME"_"$VERSION"-"$RELEASE"_"$ARCH"
|
|
|
|
|
|
|
|
GIT_RELEASE_URL=https://scodoc.org/git/viennet/ScoDoc/archive/${RELEASE_TAG}.tar.gz
|
|
|
|
|
|
|
|
SCODOC_USER=scodoc
|
|
|
|
# Safety checks
|
|
|
|
[ -z "$FACTORY_DIR" ] && die "empty FACTORY_DIR"
|
|
|
|
[ "$(id -nu)" != "$SCODOC_USER" ] && die "Erreur: le script $0 doit être lancé par l'utilisateur $SCODOC_USER"
|
|
|
|
|
|
|
|
# Création répertoire du paquet, et de opt
|
|
|
|
slash="$FACTORY_DIR"/"$DEST_DIR"
|
|
|
|
optdir="$slash"/opt
|
|
|
|
|
|
|
|
[ -e "$slash" ] && die "Directory $slash already exists"
|
|
|
|
mkdir -p "$optdir" || die "mkdir failure for $optdir"
|
|
|
|
|
|
|
|
# On récupère la release
|
|
|
|
archive="$FACTORY_DIR"/"$PACKAGE_NAME-$RELEASE_TAG".tar.gz
|
|
|
|
echo "Downloading $GIT_RELEASE_URL ..."
|
|
|
|
curl -o "$archive" "$GIT_RELEASE_URL" || die "curl failure for $GIT_RELEASE_URL"
|
|
|
|
|
|
|
|
# On décomprime
|
|
|
|
# normalement le résultat s'appelle "scodoc" et va dans opt
|
|
|
|
(cd "$optdir" && tar xfz "$archive") || die "tar extraction failure"
|
|
|
|
|
|
|
|
SCODOC_DIR="$optdir"/scodoc
|
|
|
|
[ -d "$SCODOC_DIR" ] || die "die Erreur: $SCODOC_DIR inexistant"
|
|
|
|
|
|
|
|
# Puis on déplace les fichiers de config (nginx, systemd, ...)
|
|
|
|
# nginx:
|
|
|
|
mkdir -p "$slash"/etc/nginx/sites-available || die "can't mkdir nginx config"
|
|
|
|
cp -p "$SCODOC_DIR"/tools/etc/scodoc9.nginx "$slash"/etc/nginx/sites-available/ || die "can't copy nginx config"
|
|
|
|
# systemd
|
|
|
|
mkdir -p "$slash"/etc/systemd/system/ || die "can't mkdir systemd config"
|
|
|
|
cp -p "$SCODOC_DIR"/tools/etc/scodoc9.service "$slash"/etc/systemd/system/ || die "can't copy scodoc9.service"
|
|
|
|
|
|
|
|
# Répertoire DEBIAN
|
|
|
|
mv "$SCODOC_DIR"/tools/debian "$slash"/DEBIAN || die "can't install DEBIAN dir"
|
|
|
|
chmod 755 "$slash"/DEBIAN/*inst || die "can't chmod debian scripts"
|
|
|
|
|
2021-08-24 18:55:58 +02:00
|
|
|
# ------------ CREATION DU VIRTUALENV
|
2021-08-24 23:36:58 +02:00
|
|
|
#echo "Creating python3 virtualenv..."
|
|
|
|
#(cd $SCODOC_DIR && python3 -m venv venv) || die "error creating Python 3 virtualenv"
|
2021-08-24 17:35:39 +02:00
|
|
|
|
2021-08-24 18:55:58 +02:00
|
|
|
# ------------ INSTALL DES PAQUETS PYTHON (3.9)
|
|
|
|
# pip in our env, as user "scodoc"
|
2021-08-24 23:36:58 +02:00
|
|
|
#(cd $SCODOC_DIR && source venv/bin/activate && pip install wheel && pip install -r requirements-3.9.txt) || die "Error installing python packages"
|
2021-08-24 18:55:58 +02:00
|
|
|
|
|
|
|
# -------- THE END
|
|
|
|
echo "Terminé."
|
|
|
|
echo "Après vérification, construire le paquet .deb avec:"
|
|
|
|
echo " dpkg-deb --build --root-owner-group $DEST_DIR"
|
2021-08-24 17:35:39 +02:00
|
|
|
|
|
|
|
|