mirror of
https://github.com/tteck/Proxmox.git
synced 2025-02-15 06:09:15 +01:00
Update tandoorrecipes-install.sh
This commit is contained in:
parent
09cd0e6e1f
commit
1aa4cef8bc
1 changed files with 86 additions and 75 deletions
|
@ -60,100 +60,111 @@ apt-get -qqy upgrade &>/dev/null
|
||||||
msg_ok "Updated Container OS"
|
msg_ok "Updated Container OS"
|
||||||
|
|
||||||
msg_info "Installing Dependencies"
|
msg_info "Installing Dependencies"
|
||||||
apt-get update &>/dev/null
|
|
||||||
apt-get -qqy install \
|
apt-get -qqy install \
|
||||||
git \
|
git \
|
||||||
build-essential \
|
python3 \
|
||||||
pkgconf \
|
python3-pip \
|
||||||
libssl-dev \
|
python3-venv \
|
||||||
libmariadb-dev-compat \
|
nginx \
|
||||||
libpq-dev \
|
|
||||||
curl \
|
curl \
|
||||||
|
libpq-dev \
|
||||||
|
postgresql \
|
||||||
|
libsasl2-dev \
|
||||||
|
python3-dev \
|
||||||
|
libldap2-dev \
|
||||||
|
libssl-dev \
|
||||||
sudo &>/dev/null
|
sudo &>/dev/null
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
WEBVAULT=$(curl -s https://api.github.com/repos/dani-garcia/bw_web_builds/releases/latest \
|
msg_info "Cloning & Preparation of Recipes"
|
||||||
| grep "tag_name" \
|
git clone https://github.com/vabene1111/recipes.git -b master
|
||||||
| awk '{print substr($2, 2, length($2)-3) }') \
|
mv recipes /var/www
|
||||||
|
cd /var/www/recipes
|
||||||
|
sudo useradd recipes
|
||||||
|
chown -R recipes:www-data /var/www/recipes
|
||||||
|
python3 -m venv /var/www/recipes
|
||||||
|
msg_ok "Cloning & Preparation done"
|
||||||
|
|
||||||
VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest \
|
msg_ok "Installing NodeJS"
|
||||||
| grep "tag_name" \
|
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
|
||||||
| awk '{print substr($2, 2, length($2)-3) }') \
|
sudo apt install -y nodejs
|
||||||
|
msg_ok "Installed NodeJS"
|
||||||
|
|
||||||
msg_info "Installing Rust"
|
msg_ok "Installing Project Requirements"
|
||||||
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal &>/dev/null
|
/var/www/recipes/bin/pip3 install -r requirements.txt
|
||||||
echo 'export PATH=~/.cargo/bin:$PATH' >> ~/.bashrc &>/dev/null
|
cd ./vue
|
||||||
export PATH=~/.cargo/bin:$PATH &>/dev/null
|
yarn install
|
||||||
which rustc &>/dev/null
|
yarn build
|
||||||
msg_ok "Installed Rust"
|
msg_ok "Installed Project Requirements"
|
||||||
|
|
||||||
msg_info "Building Vaultwarden ${VAULT} (Patience)"
|
msg_ok "Setup Database started"
|
||||||
git clone https://github.com/dani-garcia/vaultwarden &>/dev/null
|
sudo -u postgres psql
|
||||||
cd vaultwarden
|
PWDJANGO=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 23 ; echo '')
|
||||||
cargo build --features "sqlite,mysql,postgresql" --release &>/dev/null
|
CREATE DATABASE djangodb;
|
||||||
msg_ok "Built Vaultwarden ${VAULT}"
|
CREATE USER djangouser WITH PASSWORD '$PWDJANGO';
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE djangodb TO djangouser;
|
||||||
|
ALTER DATABASE djangodb OWNER TO djangouser;
|
||||||
|
ALTER ROLE djangouser SET client_encoding TO 'utf8';
|
||||||
|
ALTER ROLE djangouser SET default_transaction_isolation TO 'read committed';
|
||||||
|
ALTER ROLE djangouser SET timezone TO 'UTC';
|
||||||
|
ALTER USER djangouser WITH SUPERUSER;
|
||||||
|
exit
|
||||||
|
msg_ok "Setup Database finished"
|
||||||
|
|
||||||
addgroup --system vaultwarden &>/dev/null
|
msg_ok "Setup .env started"
|
||||||
adduser --system --home /opt/vaultwarden --shell /usr/sbin/nologin --no-create-home --gecos 'vaultwarden' --ingroup vaultwarden --disabled-login --disabled-password vaultwarden &>/dev/null
|
wget https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template -O /var/www/recipes/.env
|
||||||
mkdir -p /opt/vaultwarden/bin
|
SECRETKEY=$(base64 /dev/urandom | head -c50)
|
||||||
mkdir -p /opt/vaultwarden/data
|
msg_ok "Setup .env finished"
|
||||||
cp target/release/vaultwarden /opt/vaultwarden/bin/
|
|
||||||
|
|
||||||
msg_info "Downloading Web-Vault ${WEBVAULT}"
|
|
||||||
curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$WEBVAULT/bw_web_$WEBVAULT.tar.gz &>/dev/null
|
|
||||||
tar -xzf bw_web_$WEBVAULT.tar.gz -C /opt/vaultwarden/ &>/dev/null
|
|
||||||
msg_ok "Downloaded Web-Vault ${WEBVAULT}"
|
|
||||||
|
|
||||||
cat <<EOF > /opt/vaultwarden/.env
|
|
||||||
## https://github.com/dani-garcia/vaultwarden/blob/main/.env.template
|
|
||||||
# ADMIN_TOKEN=Vy2VyYTTsKPv8W5aEOWUbB/Bt3DEKePbHmI4m9VcemUMS2rEviDowNAFqYi1xjmp
|
|
||||||
ROCKET_ADDRESS=0.0.0.0
|
|
||||||
DATA_FOLDER=/opt/vaultwarden/data
|
|
||||||
DATABASE_MAX_CONNS=10
|
|
||||||
WEB_VAULT_FOLDER=/opt/vaultwarden/web-vault
|
|
||||||
WEB_VAULT_ENABLED=true
|
|
||||||
EOF
|
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
chown -R vaultwarden:vaultwarden /opt/vaultwarden/
|
service_path="/etc/systemd/system/gunicorn_recipes.service" &>/dev/null
|
||||||
chown root:root /opt/vaultwarden/bin/vaultwarden
|
|
||||||
chmod +x /opt/vaultwarden/bin/vaultwarden
|
|
||||||
chown -R root:root /opt/vaultwarden/web-vault/
|
|
||||||
chmod +r /opt/vaultwarden/.env
|
|
||||||
service_path="/etc/systemd/system/vaultwarden.service" &>/dev/null
|
|
||||||
|
|
||||||
echo "[Unit]
|
echo "[Unit]
|
||||||
Description=Bitwarden Server (Powered by Vaultwarden)
|
Description=gunicorn daemon for recipes
|
||||||
Documentation=https://github.com/dani-garcia/vaultwarden
|
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=vaultwarden
|
Type=simple
|
||||||
Group=vaultwarden
|
Restart=always
|
||||||
EnvironmentFile=-/opt/vaultwarden/.env
|
RestartSec=3
|
||||||
ExecStart=/opt/vaultwarden/bin/vaultwarden
|
User=recipes
|
||||||
LimitNOFILE=65535
|
Group=www-data
|
||||||
LimitNPROC=4096
|
WorkingDirectory=/var/www/recipes
|
||||||
PrivateTmp=true
|
EnvironmentFile=/var/www/recipes/.env
|
||||||
PrivateDevices=true
|
ExecStart=/var/www/recipes/bin/gunicorn --error-logfile /tmp/gunicorn_err.log --log-level debug --capture-output --bind unix:/var/www/recipes/recipes.sock recipes.wsgi:application
|
||||||
ProtectHome=true
|
|
||||||
ProtectSystem=strict
|
|
||||||
DevicePolicy=closed
|
|
||||||
ProtectControlGroups=yes
|
|
||||||
ProtectKernelModules=yes
|
|
||||||
ProtectKernelTunables=yes
|
|
||||||
RestrictNamespaces=yes
|
|
||||||
RestrictRealtime=yes
|
|
||||||
MemoryDenyWriteExecute=yes
|
|
||||||
LockPersonality=yes
|
|
||||||
WorkingDirectory=/opt/vaultwarden
|
|
||||||
ReadWriteDirectories=/opt/vaultwarden/data
|
|
||||||
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target" > $service_path
|
WantedBy=multi-user.target" > $service_path
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable --now vaultwarden.service &>/dev/null
|
systemctl enable --now gunicorn_recipes.service &>/dev/null
|
||||||
msg_ok "Created Service"
|
msg_ok "Created Service"
|
||||||
|
|
||||||
|
msg_ok "Creating NGINX Config"
|
||||||
|
nginxconfig_path="/etc/nginx/conf.d/recipes.conf" &>/dev/null
|
||||||
|
|
||||||
|
echo "server {
|
||||||
|
listen 8002;
|
||||||
|
#access_log /var/log/nginx/access.log;
|
||||||
|
#error_log /var/log/nginx/error.log;
|
||||||
|
|
||||||
|
# serve media files
|
||||||
|
location /static {
|
||||||
|
alias /var/www/recipes/staticfiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /media {
|
||||||
|
alias /var/www/recipes/mediafiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_pass http://unix:/var/www/recipes/recipes.sock;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}" > $nginxconfig_path
|
||||||
|
systemctl reload nginx
|
||||||
|
msg_ok "Created NGINX Config"
|
||||||
|
|
||||||
PASS=$(grep -w "root" /etc/shadow | cut -b6);
|
PASS=$(grep -w "root" /etc/shadow | cut -b6);
|
||||||
if [[ $PASS != $ ]]; then
|
if [[ $PASS != $ ]]; then
|
||||||
msg_info "Customizing Container"
|
msg_info "Customizing Container"
|
||||||
|
@ -173,7 +184,7 @@ msg_ok "Customized Container"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
apt-get autoremove >/dev/null
|
apt-get autoremove -y >/dev/null
|
||||||
apt-get autoclean >/dev/null
|
apt-get autoclean >/dev/null
|
||||||
rm -rf /var/{cache,log}/* /var/lib/apt/lists/*
|
rm -rf /var/{cache,log}/* /var/lib/apt/lists/*
|
||||||
msg_ok "Cleaned"
|
msg_ok "Cleaned"
|
Loading…
Add table
Add a link
Reference in a new issue