|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2026 community-scripts ORG |
| 4 | +# Author: MickLesk (CanbiZ) |
| 5 | +# License: MIT | https://github.com/community-scripts/DevScripts/raw/main/LICENSE |
| 6 | +# Source: https://github.com/blinkospace/blinko |
| 7 | + |
| 8 | +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" |
| 9 | +color |
| 10 | +verb_ip6 |
| 11 | +catch_errors |
| 12 | +setting_up_container |
| 13 | +network_check |
| 14 | +update_os |
| 15 | + |
| 16 | +NODE_VERSION="24" NODE_MODULE="bun" setup_nodejs |
| 17 | +PG_VERSION="17" setup_postgresql |
| 18 | +PG_DB_NAME="blinko" PG_DB_USER="blinko" setup_postgresql_db |
| 19 | + |
| 20 | +fetch_and_deploy_gh_release "blinko" "blinkospace/blinko" "tarball" |
| 21 | + |
| 22 | +msg_info "Building Blinko" |
| 23 | +cd /opt/blinko |
| 24 | +$STD bun install |
| 25 | +$STD bunx prisma generate |
| 26 | +$STD bun run build:web |
| 27 | +$STD bun run build:seed |
| 28 | +# The server resolves its web root as ../server/public and lute/vditor next to its own bundle |
| 29 | +mv dist/public server/public |
| 30 | +cp -r server/lute.min.js server/vditor dist/ |
| 31 | +msg_ok "Built Blinko" |
| 32 | + |
| 33 | +msg_info "Configuring Blinko" |
| 34 | +mkdir -p /opt/blinko_data/storage |
| 35 | +# Blinko keeps uploads, the vector index and backups in .blinko under its working directory |
| 36 | +ln -s /opt/blinko_data/storage /opt/blinko/.blinko |
| 37 | +cat <<EOF >/opt/blinko_data/.env |
| 38 | +NODE_ENV=production |
| 39 | +DATABASE_URL=postgresql://blinko:${PG_DB_PASS}@localhost:5432/blinko |
| 40 | +TRUST_PROXY=1 |
| 41 | +EOF |
| 42 | +chmod 600 /opt/blinko_data/.env |
| 43 | +msg_ok "Configured Blinko" |
| 44 | + |
| 45 | +msg_info "Creating Service" |
| 46 | +cat <<EOF >/etc/systemd/system/blinko.service |
| 47 | +[Unit] |
| 48 | +Description=Blinko |
| 49 | +After=network.target postgresql.service |
| 50 | +Requires=postgresql.service |
| 51 | +
|
| 52 | +[Service] |
| 53 | +Type=simple |
| 54 | +User=root |
| 55 | +WorkingDirectory=/opt/blinko |
| 56 | +EnvironmentFile=/opt/blinko_data/.env |
| 57 | +ExecStartPre=/opt/blinko/node_modules/.bin/prisma migrate deploy |
| 58 | +ExecStartPre=/usr/bin/node /opt/blinko/dist/seed.js |
| 59 | +ExecStart=/usr/bin/node /opt/blinko/dist/index.js |
| 60 | +Restart=on-failure |
| 61 | +RestartSec=5 |
| 62 | +
|
| 63 | +[Install] |
| 64 | +WantedBy=multi-user.target |
| 65 | +EOF |
| 66 | +systemctl enable -q --now blinko |
| 67 | +msg_ok "Created Service" |
| 68 | + |
| 69 | +motd_ssh |
| 70 | +customize |
| 71 | +cleanup_lxc |
0 commit comments