diff options
author | szaimen <szaimen@e.mail.de> | 2020-09-01 20:27:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-01 20:27:52 +0300 |
commit | 981f3ea234525995855e52ad1d394429bd8c0fdc (patch) | |
tree | fea72c60efcf24cf8dfa10e6f8be7ce555b10735 /apps/bitwarden_registration.sh | |
parent | 05dce0fcac6b1dd2497d836b70d1fc4312c48f31 (diff) |
add option to disable the admin-panel for bitwarden_rs (#1394)
Co-authored-by: Daniel Hansson <github@hanssonit.se>
Diffstat (limited to 'apps/bitwarden_registration.sh')
-rw-r--r-- | apps/bitwarden_registration.sh | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/apps/bitwarden_registration.sh b/apps/bitwarden_registration.sh new file mode 100644 index 00000000..306f55a1 --- /dev/null +++ b/apps/bitwarden_registration.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/ + +# shellcheck disable=2034,2059 +true +# shellcheck source=lib.sh +. <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh) + +# Check for errors + debug code and abort if something isn't right +# 1 = ON +# 0 = OFF +DEBUG=0 +debug_mode + +# Must be root +root_check + +# Check if Bitwarden is already installed +print_text_in_color "$ICyan" "Checking if Bitwarden is already installed..." +if is_docker_running +then + if docker ps -a --format '{{.Names}}' | grep -Eq "bitwarden"; + then + if [ ! -d /root/bwdata ] [ ! -d "$BITWARDEN_HOME"/bwdata ] + then + msg_box "It seems like 'Bitwarden' isn't installed.\n\nYou cannot run this script." + exit 1 + fi + else + msg_box "It seems like 'Bitwarden' isn't installed.\n\nYou cannot run this script." + exit 1 + fi +else + msg_box "It seems like 'Bitwarden' isn't installed.\n\nYou cannot run this script." + exit 1 +fi + +# Yes or No? +choice=$(whiptail --title "Bitwarden Registration" --radiolist "Do you want to disable Bitwarden User Registration?\nSelect by pressing the spacebar\nYou can view this menu later by running 'sudo bash $SCRIPTS/menu.sh'" "$WT_HEIGHT" "$WT_WIDTH" 4 \ +"Yes" "(Disable public user registration)" OFF \ +"No" "(Enable public user registration)" OFF 3>&1 1>&2 2>&3) + +case "$choice" in + "Yes") + clear + print_text_in_color "$ICyan" "Disabling Bitwarden User Regitration..." + # Disable + if [ -f /root/bwdata/env/global.override.env ] + then + sed -i "s|globalSettings__disableUserRegistration=.*|globalSettings__disableUserRegistration=true|g" /root/bwdata/env/global.override.env + # Restart Bitwarden + install_if_not curl + cd /root + curl_to_dir "https://raw.githubusercontent.com/bitwarden/core/master/scripts" "bitwarden.sh" "/root" + chmod +x /root/bitwarden.sh + check_command ./bitwarden.sh restart + elif [ -f "$BITWARDEN_HOME"/bwdata/env/global.override.env ] + then + sed -i "s|globalSettings__disableUserRegistration=.*|globalSettings__disableUserRegistration=true|g" "$BITWARDEN_HOME"/bwdata/env/global.override.env + # Restart Bitwarden + install_if_not curl + cd "$BITWARDEN_HOME" + curl_to_dir "https://raw.githubusercontent.com/bitwarden/core/master/scripts" "bitwarden.sh" "$BITWARDEN_HOME" + chown "$BITWARDEN_USER":"$BITWARDEN_USER" "$BITWARDEN_HOME"/bitwarden.sh + chmod +x "$BITWARDEN_HOME"/bitwarden.sh + check_command systemctl restart bitwarden + fi + ;; + "No") + clear + print_text_in_color "$ICyan" "Enabling Bitwarden User Registration..." + # Enable + if [ -f /root/bwdata/env/global.override.env ] + then + sed -i "s|globalSettings__disableUserRegistration=.*|globalSettings__disableUserRegistration=false|g" /root/bwdata/env/global.override.env + # Restart Bitwarden + install_if_not curl + cd /root + curl_to_dir "https://raw.githubusercontent.com/bitwarden/core/master/scripts" "bitwarden.sh" "/root" + chmod +x /root/bitwarden.sh + check_command ./bitwarden.sh restart + elif [ -f "$BITWARDEN_HOME"/bwdata/env/global.override.env ] + then + sed -i "s|globalSettings__disableUserRegistration=.*|globalSettings__disableUserRegistration=false|g" "$BITWARDEN_HOME"/bwdata/env/global.override.env + # Restart Bitwarden + install_if_not curl + cd "$BITWARDEN_HOME" + curl_to_dir "https://raw.githubusercontent.com/bitwarden/core/master/scripts" "bitwarden.sh" "$BITWARDEN_HOME" + chown "$BITWARDEN_USER":"$BITWARDEN_USER" "$BITWARDEN_HOME"/bitwarden.sh + chmod +x "$BITWARDEN_HOME"/bitwarden.sh + check_command systemctl restart bitwarden + fi + ;; + *) + ;; +esac |