2024-07-24 18:41:04 +08:00
|
|
|
|
#!/bin/bash
|
2024-11-18 23:12:52 +08:00
|
|
|
|
declare installation_directory=$1
|
|
|
|
|
declare web_service_port=$2
|
2024-07-24 18:41:04 +08:00
|
|
|
|
|
2024-11-18 23:12:52 +08:00
|
|
|
|
declare admin_password
|
|
|
|
|
read -p "请输入管理员密码(不输入则关闭管理员功能):" admin_password
|
2024-07-24 18:41:04 +08:00
|
|
|
|
|
2024-11-18 23:12:52 +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
|
2024-11-18 23:12:52 +08:00
|
|
|
|
- ADMIN_TOKEN="$admin_password"
|
2024-07-24 18:41:04 +08:00
|
|
|
|
volumes:
|
|
|
|
|
- ./:/data/
|
|
|
|
|
ports:
|
2024-11-18 23:12:52 +08:00
|
|
|
|
- "${web_service_port}:80"
|
2024-07-24 18:41:04 +08:00
|
|
|
|
EOF
|
|
|
|
|
|
2024-11-18 23:12:52 +08:00
|
|
|
|
if [[ -z $admin_password ]];then
|
2024-09-22 20:42:23 +08:00
|
|
|
|
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
|
2024-11-18 23:12:52 +08:00
|
|
|
|
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
|
2024-09-23 18:25:54 +08:00
|
|
|
|
docker compose up -d || echo "安装失败" && exit
|
2024-11-18 23:12:52 +08:00
|
|
|
|
echo "需要反向代理,使用HTTPS才能正常使用"
|