SHARE
TWEET

Untitled

a guest Oct 21st, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2. set -e
  3.  
  4. cat << "EOF"
  5.  _     _ _                         _            
  6. | |__ (_) |___      ____ _ _ __ __| | ___ _ __  
  7. | '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \
  8. | |_) | | |_ \ V  V / (_| | | | (_| |  __/ | | |
  9. |_.__/|_|\__| \_/\_/ \__,_|_|  \__,_|\___|_| |_|
  10.  
  11. EOF
  12.  
  13. cat << EOF
  14. Open source password management solutions
  15. Copyright 2015-$(date +'%Y'), 8bit Solutions LLC
  16. https://bitwarden.com, https://github.com/bitwarden
  17.  
  18. ===================================================
  19.  
  20. EOF
  21.  
  22. docker --version
  23. docker-compose --version
  24.  
  25. echo ""
  26.  
  27. # Setup
  28.  
  29. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  30. SCRIPT_NAME=`basename "$0"`
  31. SCRIPT_PATH="$DIR/$SCRIPT_NAME"
  32. OUTPUT="$DIR/bwdata"
  33. if [ $# -eq 2 ]
  34. then
  35.     OUTPUT=$2
  36. fi
  37.  
  38. SCRIPTS_DIR="$OUTPUT/scripts"
  39. GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/server/master"
  40. COREVERSION="1.32.0"
  41. WEBVERSION="2.12.0"
  42.  
  43. # Functions
  44.  
  45. function downloadSelf() {
  46.     curl -s -o $SCRIPT_PATH $GITHUB_BASE_URL/scripts/bitwarden.sh
  47.     chmod u+x $SCRIPT_PATH
  48. }
  49.  
  50. function downloadRunFile() {
  51.     if [ ! -d "$SCRIPTS_DIR" ]
  52.     then
  53.         mkdir $SCRIPTS_DIR
  54.     fi
  55.     curl -s -o $SCRIPTS_DIR/run.sh $GITHUB_BASE_URL/scripts/run.sh
  56.     chmod u+x $SCRIPTS_DIR/run.sh
  57.     rm -f $SCRIPTS_DIR/install.sh
  58. }
  59.  
  60. function checkOutputDirExists() {
  61.     if [ ! -d "$OUTPUT" ]
  62.     then
  63.         echo "Cannot find a Bitwarden installation at $OUTPUT."
  64.         exit 1
  65.     fi
  66. }
  67.  
  68. function checkOutputDirNotExists() {
  69.     if [ -d "$OUTPUT/docker" ]
  70.     then
  71.         echo "Looks like Bitwarden is already installed at $OUTPUT."
  72.         exit 1
  73.     fi
  74. }
  75.  
  76. # Commands
  77.  
  78. if [ "$1" == "install" ]
  79. then
  80.     checkOutputDirNotExists
  81.     mkdir -p $OUTPUT
  82.     downloadRunFile
  83.     $SCRIPTS_DIR/run.sh install $OUTPUT $COREVERSION $WEBVERSION
  84. elif [ "$1" == "start" -o "$1" == "restart" ]
  85. then
  86.     checkOutputDirExists
  87.     $SCRIPTS_DIR/run.sh restart $OUTPUT $COREVERSION $WEBVERSION
  88. elif [ "$1" == "update" ]
  89. then
  90.     checkOutputDirExists
  91.     downloadRunFile
  92.     $SCRIPTS_DIR/run.sh update $OUTPUT $COREVERSION $WEBVERSION
  93. elif [ "$1" == "rebuild" ]
  94. then
  95.     checkOutputDirExists
  96.     $SCRIPTS_DIR/run.sh rebuild $OUTPUT $COREVERSION $WEBVERSION
  97. elif [ "$1" == "updateconf" ]
  98. then
  99.     checkOutputDirExists
  100.     $SCRIPTS_DIR/run.sh updateconf $OUTPUT $COREVERSION $WEBVERSION
  101. elif [ "$1" == "updatedb" ]
  102. then
  103.     checkOutputDirExists
  104.     $SCRIPTS_DIR/run.sh updatedb $OUTPUT $COREVERSION $WEBVERSION
  105. elif [ "$1" == "stop" ]
  106. then
  107.     checkOutputDirExists
  108.     $SCRIPTS_DIR/run.sh stop $OUTPUT $COREVERSION $WEBVERSION
  109. elif [ "$1" == "updateself" ]
  110. then
  111.     downloadSelf && echo "Updated self." && exit
  112. else
  113.     echo "No command found."
  114. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top