From 3410b833365e6a4fc5deef685c1a303a77871b60 Mon Sep 17 00:00:00 2001 From: Maxime Renou Date: Tue, 8 Mar 2022 11:39:35 +0100 Subject: [PATCH] hello --- index.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 index.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..05c7c20 --- /dev/null +++ b/index.php @@ -0,0 +1,53 @@ +#!/usr/bin/env php + $command"); + exec($command, $output, $return); + foreach ($output as $line) + line($line); + return $return === 0; +} + +$repository = 'git@git.bluesquare.io:bag/cli.git'; +$home = $_SERVER['HOME'] ?? ($_SERVER['HOMEPATH'] ?? $_SERVER['HOMEDRIVE']); +$dir = __DIR__; + +line("Répertoire utilisateur détecté : $home"); + +if (is_dir("$home/.bag")) { + line("Le dossier $home/.bag existe déjà."); + exit(1); +} + +if (!run("cd $home && git clone $repository .bag")) + exit(1); + +if (!run("cd $home/.bag && composer install")) + exit(1); + +$source = file_exists("$home/.zshrc") ? "$home/.zshrc" : "$home/.bashrc"; +$contents = file_exists($source) ? file_get_contents($source) : ""; + +if (strpos($contents, ".bag/bin") === false) { + line("----------------------------------------------------"); + line("----------------------------------------------------"); + line("Pour pouvoir utiliser la commande `bag` :"); + line("echo 'export PATH=\"$home/.bag/bin:\$PATH\"' >> $source"); + line("source $source"); + line("----------------------------------------------------"); +} + +exit(0);