diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..74dc4ae --- /dev/null +++ b/install.sh @@ -0,0 +1,39 @@ +#!/bin/bash -e + +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized + +echo "Vérification de l'installation de bbot" + +# Check if nvm, curl, node 12 and pm2 are installed +install_require() { + sudo apt update + [[ ! $(which curl) ]] && sudo apt install curl + [[ ! -f $HOME/.nvm/nvm.sh ]] && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash + \. "$NVM_DIR/nvm.sh" + nvm install 12 + nvm use 12 + [[ ! $(which pm2) ]] && npm install pm2 -g +} + +prepare_environment() { + # Create .env files from templates + [[ ! -f $MY_PATH/.env ]] && cp $MY_PATH/.env.example $MY_PATH/.env + + # Install bbot + [[ ! -d $MY_PATH/node_modules/bbot ]] && npm install bbot + + # Grant shell script executable + chmod u+x $MY_PATH/src/shell/* + + # Install duniterpy.key + [[ ! $(pip3 freeze | grep duniterpy) ]] && pip3 install duniterpy || echo "duniterpy is still installed" + + # install Silkaj + sudo apt install libsodium23 + pip3 install silkaj --user --upgrade +} + + +install_require +prepare_environment diff --git a/src/shell/.env.example b/src/shell/.env.example index b741c7a..657bc43 100644 --- a/src/shell/.env.example +++ b/src/shell/.env.example @@ -1,2 +1,4 @@ API_TOKEN="" API_ID="" +node="" +silkaj="$HOME/.local/bin/silkaj -p $node" diff --git a/src/shell/functions.sh b/src/shell/functions.sh index f870e24..dc5b538 100755 --- a/src/shell/functions.sh +++ b/src/shell/functions.sh @@ -133,4 +133,4 @@ history_account() { echo "\`\`\`$result\`\`\`" } -#[[ $(type $@ | grep "est une fonction") ]] && $@ || echo "Veuillez préciser votre commande" +#[[ $(type $1 | grep "est une fonction") ]] && $@ || echo "Veuillez préciser votre commande"