Skip to content

Commit

Permalink
feat: make scripts portable across unix systems
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-roudaut-crea authored and bouttier committed May 22, 2023
1 parent f63581e commit e80a455
Show file tree
Hide file tree
Showing 26 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions backend/geonature/utils/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ def create_frontend_module_config(module_code, output_file=None):


def nvm_available():
return run(["/bin/bash", "-i", "-c", "type -t nvm"], stdout=DEVNULL).returncode == 0
return run(["/usr/bin/env bash", "-i", "-c", "type -t nvm"], stdout=DEVNULL).returncode == 0


def install_frontend_dependencies(module_frontend_path):
cmd = ["npm", "ci", "--omit=dev", "--omit=peer"]
if nvm_available():
with (FRONTEND_DIR / ".nvmrc").open("r") as f:
node_version = f.read().strip()
cmd = ["/bin/bash", "-i", "-c", f"nvm exec {node_version} {' '.join(cmd)}"]
cmd = ["/usr/bin/env bash", "-i", "-c", f"nvm exec {node_version} {' '.join(cmd)}"]
run(cmd, check=True, cwd=module_frontend_path)


def build_frontend():
cmd = ["npm", "run", "build"]
if nvm_available():
cmd = ["/bin/bash", "-i", "-c", f"nvm exec {' '.join(cmd)}"]
cmd = ["/usr/bin/env bash", "-i", "-c", f"nvm exec {' '.join(cmd)}"]
run(cmd, check=True, cwd=str(FRONTEND_DIR))
2 changes: 1 addition & 1 deletion data/migrations/2.0.1to2.1.0.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# faux sudo car sinon la commande "sudo -n -u" ne le demande pas
sudo ls
Expand Down
4 changes: 2 additions & 2 deletions data/migrations/2.4.0to2.4.1_insert_departments.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

filepath=$(realpath $0)
GEONATURE_ROOT=$(dirname $(dirname $(dirname $filepath)))
Expand All @@ -16,4 +16,4 @@ export PGPASSWORD=$user_pg_pass;psql -h $db_host -U $user_pg -d $db_name -f $GEO
sudo -n -u postgres -s psql -d $db_name -c "DROP TABLE ref_geo.temp_fr_departements;" &>> $GEONATURE_ROOT/var/log/insert_departements.log

rm $GEONATURE_ROOT/tmp/geonature/departement_admin_express_2020-02.zip
rm $GEONATURE_ROOT/tmp/geonature/fr_departements.sql
rm $GEONATURE_ROOT/tmp/geonature/fr_departements.sql
2 changes: 1 addition & 1 deletion data/migrations/missing_grid.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
. ../../config/settings.ini
cd ../../

Expand Down
2 changes: 1 addition & 1 deletion data/migrations/v1tov2/migratetoV2.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash
. migratetoV2.ini
. ../../../config/settings.ini
echo $geonature1user
Expand Down
2 changes: 1 addition & 1 deletion data/migrations/v1tov2/my_organisme/mymigratetoV2.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#! /usr/bin/env bash
. ../migratetoV2.ini
. mymigratetov2.ini
. ../../../../config/settings.ini
Expand Down
2 changes: 1 addition & 1 deletion data/migrations/v1tov2/old/v1_compat.sh.old
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

. v1_compat.ini
. ../../../config/settings.ini
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/backup/pgdump2ftpbackup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

BKPDIR="/var/backups/pgsql"
TODAY=`date +%F`
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/import_ginco/import_ca.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

. settings.ini
# export all variable in settings.ini
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/import_ginco/import_mtd.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

. settings.ini
# export all variable in settings.ini
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
. ../settings.ini

mkdir -p /tmp/taxhub
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/import_ginco/restore_db.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Scripts qui restaure une BDD GINCO à parit d'un DUMP SQL
# Puis crée un Foreign Data Wrapper entre la base restaurée et la base GeoNature cible
Expand Down
4 changes: 2 additions & 2 deletions data/scripts/ref_geo/insert_reg.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

filepath=$(realpath $0)
GEONATURE_ROOT=$(dirname $(dirname $(dirname $filepath)))
Expand All @@ -15,4 +15,4 @@ export PGPASSWORD=$user_pg_pass;psql -h $db_host -U $user_pg -d $db_name -f $GEO
sudo -n -u postgres psql -d $db_name -c "DROP TABLE ref_geo.temp_fr_regions;" &>> $GEONATURE_ROOT/var/log/insert_reg.log

# rm $GEONATURE_ROOT/tmp/geonature/reg_fr_admin_express_2020-07.zip
rm $GEONATURE_ROOT/tmp/geonature/fr_regions.sql
rm $GEONATURE_ROOT/tmp/geonature/fr_regions.sql
2 changes: 1 addition & 1 deletion data/scripts/sensi/import_sensi_depobio.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Script remplaçant les règles de sensibilité nationales et régionales intégrées dans GeoNature, par les règles départementales.
# Utilisé pour DEPOBIO pour disposer des règles de sensibilité à jour, au niveau départemantal.
Expand Down
2 changes: 1 addition & 1 deletion install/00_install_nvm.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash


echo "Installation de nvm"
Expand Down
2 changes: 1 addition & 1 deletion install/01_install_backend.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# DESC: Usage help
# ARGS: None
Expand Down
2 changes: 1 addition & 1 deletion install/02_configure_systemd.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash


set -eo pipefail
Expand Down
2 changes: 1 addition & 1 deletion install/03_create_db.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash


set -eo pipefail
Expand Down
2 changes: 1 addition & 1 deletion install/04_install_gn_modules.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -eo pipefail

Expand Down
2 changes: 1 addition & 1 deletion install/05_install_frontend.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# DESC: Usage help
# ARGS: None
Expand Down
2 changes: 1 addition & 1 deletion install/06_configure_apache.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
. "${SCRIPT_DIR}/utils"
Expand Down
2 changes: 1 addition & 1 deletion install/install_all/install_all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion install/migration/beta4tobeta5.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#/usr/bin/env bash

BASE_DIR=$(readlink -e "${0%/*}")

Expand Down
2 changes: 1 addition & 1 deletion install/migration/migration.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

SERVICES=("geonature" "geonature-worker" "taxhub" "usershub")

Expand Down
2 changes: 1 addition & 1 deletion install/utils
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash


export BASE_DIR=$(dirname "${SCRIPT_DIR}")
Expand Down
2 changes: 1 addition & 1 deletion lint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# backend
black .
Expand Down

0 comments on commit e80a455

Please sign in to comment.