linuxtool/Config/Docker/Installs/vaultwarden.sh

45 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2024-07-24 18:41:04 +08:00
#!/bin/bash
declare installation_directory=$1
declare web_service_port=$2
2024-07-24 18:41:04 +08:00
declare admin_password
read -p "请输入管理员密码(不输入则关闭管理员功能):" admin_password
2024-07-24 18:41:04 +08:00
cd $installation_directory
2024-07-24 18:41:04 +08:00
cat > "docker-compose.yml" << EOF
version: '3.8'
services:
bitwarden:
image: vaultwarden/server:latest
container_name: vaultwarden
restart: always
environment:
- SIGNUPS_ALLOWED=true
- WEBSOCKET_ENABLED=true
- TZ=Asia/Shanghai
- ADMIN_TOKEN="$admin_password"
2024-07-24 18:41:04 +08:00
volumes:
- ./:/data/
ports:
- "${web_service_port}:80"
2024-07-24 18:41:04 +08:00
EOF
if [[ -z $admin_password ]];then
sed -i '/.*ADMIN_TOKEN=.*/d' "docker-compose.yml"
2024-07-24 18:41:04 +08:00
fi
mkdir templates
cd templates
wget https://github.com/wcjxixi/vaultwarden-lang-zhcn/archive/refs/heads/main.zip
unzip main.zip
rm main.zip
cd vaultwarden-lang-zhcn-main
declare admin_file=$( ls | grep "admin" | tac | head -n 1 )
declare email_file=$( ls | grep "email" | tac | head -n 1 )
mv "$admin_file" "../admin"
mv "$email_file" "../email"
2024-07-24 18:41:04 +08:00
cd ..
rm -rf vaultwarden-lang-zhcn-main
docker compose up -d || echo "安装失败" && exit
echo "需要反向代理使用HTTPS才能正常使用"