-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·129 lines (112 loc) · 5.53 KB
/
install.sh
File metadata and controls
executable file
·129 lines (112 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh
#
#==============================================================================
# GitLab Public Repository Monitor - Installer
#
# Ce script télécharge et installe la dernière version de GitLabMonitor.
# Utilisation : curl -sSL <URL_VERS_CE_SCRIPT> | sh
#==============================================================================
set -e
# Variables
DOWNLOAD_URL="https://gitlab.villejuif.fr/depots-public/gitlabmonitor/-/releases/permalink/latest/downloads/gitlab-monitor-latest.tar.gz"
INSTALL_DIR="gitlabmonitor"
TMP_ARCHIVE="/tmp/gitlab-monitor-latest.tar.gz"
# Couleurs
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
# Détection de la langue (Anglais par défaut)
LANG=${LANG:-en_US.UTF-8}
IS_FRENCH=false
if echo "$LANG" | grep -q -E '^fr'; then
IS_FRENCH=true
fi
# Messages bilingues
msg() {
if [ "$IS_FRENCH" = true ]; then
echo "$1"
else
echo "$2"
fi
}
echo "--- GitLabMonitor Installer ---"
# Vérification des dépendances
msg "Vérification des dépendances (curl, tar)..." "Checking dependencies (curl, tar)..."
if ! command -v curl >/dev/null 2>&1; then
msg "${RED}ERREUR : 'curl' n'est pas installé. Veuillez l'installer avant de continuer.${NC}" "${RED}ERROR: 'curl' is not installed. Please install it to continue.${NC}" >&2
exit 1
fi
if ! command -v tar >/dev/null 2>&1; then
msg "${RED}ERREUR : 'tar' n'est pas installé. Veuillez l'installer avant de continuer.${NC}" "${RED}ERROR: 'tar' is not installed. Please install it to continue.${NC}" >&2
exit 1
fi
# Gestion du répertoire existant
if [ -d "$INSTALL_DIR" ]; then
msg "${YELLOW}Le répertoire '$INSTALL_DIR' existe déjà.${NC}" "${YELLOW}The directory '$INSTALL_DIR' already exists.${NC}"
msg "Que souhaitez-vous faire ?" "What would you like to do?"
msg " 1) ${RED}Supprimer${NC} le répertoire existant (toutes les données seront perdues)" " 1) ${RED}Delete${NC} the existing directory (all data will be lost)"
msg " 2) ${YELLOW}Écraser${NC} les fichiers existants (le fichier 'config.conf' sera préservé)" " 2) ${YELLOW}Overwrite${NC} existing files ('config.conf' will be preserved)"
msg " 3) Choisir un ${GREEN}nouveau nom${NC} de répertoire" " 3) Choose a ${GREEN}new name${NC} for the directory"
read -p "$(msg 'Votre choix [1-3] : ' 'Your choice [1-3]: ')" choice
case "$choice" in
1)
msg "Suppression du répertoire '$INSTALL_DIR'..." "Deleting directory '$INSTALL_DIR'..."
rm -rf "$INSTALL_DIR"
;;
2)
msg "Écrasement des fichiers dans '$INSTALL_DIR'..." "Overwriting files in '$INSTALL_DIR'..."
if [ -f "${INSTALL_DIR}/config.conf" ]; then
mv "${INSTALL_DIR}/config.conf" "${INSTALL_DIR}/config.conf.bak"
msg "Sauvegarde de votre 'config.conf' existant en 'config.conf.bak'." "Backed up your existing 'config.conf' to 'config.conf.bak'."
fi
;;
3)
read -p "$(msg 'Entrez le nouveau nom du répertoire : ' 'Enter the new directory name: ')" NEW_INSTALL_DIR
if [ -z "$NEW_INSTALL_DIR" ]; then
msg "${RED}Le nom ne peut pas être vide. Abandon.${NC}" "${RED}The name cannot be empty. Aborting.${NC}" >&2
exit 1
fi
INSTALL_DIR="$NEW_INSTALL_DIR"
;;
*)
msg "${RED}Choix invalide. Abandon.${NC}" "${RED}Invalid choice. Aborting.${NC}" >&2
exit 1
;;
esac
fi
mkdir -p "$INSTALL_DIR"
msg "Installation dans le répertoire '$INSTALL_DIR'..." "Installing into directory '$INSTALL_DIR'..."
# Téléchargement et extraction
msg "Téléchargement de la dernière version..." "Downloading the latest version..."
curl -L -o "$TMP_ARCHIVE" "$DOWNLOAD_URL"
if [ ! -f "$TMP_ARCHIVE" ]; then
msg "${RED}ERREUR : Le téléchargement a échoué. Le fichier n'a pas été créé.${NC}" "${RED}ERROR: Download failed. The file was not created.${NC}" >&2
exit 1
fi
msg "Archive '${TMP_ARCHIVE}' téléchargée avec succès." "Archive '${TMP_ARCHIVE}' downloaded successfully."
msg "Extraction de l'archive..." "Extracting the archive..."
tar -xzvf "$TMP_ARCHIVE" -C "$INSTALL_DIR"
rm "$TMP_ARCHIVE"
# Restaurer la configuration si elle a été sauvegardée
if [ -f "${INSTALL_DIR}/config.conf.bak" ]; then
mv "${INSTALL_DIR}/config.conf.bak" "${INSTALL_DIR}/config.conf"
msg "Restauration de votre 'config.conf'." "Restored your 'config.conf'."
fi
# Rendre le script principal exécutable
if [ -f "${INSTALL_DIR}/gitlab-public-repo-monitor.sh" ]; then
chmod +x "${INSTALL_DIR}/gitlab-public-repo-monitor.sh"
msg "Script principal rendu exécutable." "Main script made executable."
else
msg "${RED}ERREUR : Le script principal n'a pas été trouvé après l'extraction.${NC}" "${RED}ERROR: Main script not found after extraction.${NC}" >&2
exit 1
fi
echo ""
msg "${GREEN}Installation terminée avec succès !${NC}" "${GREEN}Installation completed successfully!${NC}"
echo ""
msg "Pour commencer :" "To get started:"
msg "1. Allez dans le répertoire : cd ${INSTALL_DIR}" "1. Go to the directory: cd ${INSTALL_DIR}"
msg "2. Si ce n'est pas déjà fait, copiez la configuration : cp config.conf.example config.conf" "2. If not already done, copy the configuration: cp config.conf.example config.conf"
msg "3. Modifiez le fichier 'config.conf' avec vos paramètres." "3. Edit the 'config.conf' file with your settings."
msg "4. Lancez le script : ./gitlab-public-repo-monitor.sh" "4. Run the script: ./gitlab-public-repo-monitor.sh"
echo ""