Skip to content

Commit 5143aba

Browse files
committed
add proper ubuntu/debian package (system files, configuration, etc)
1 parent 686719d commit 5143aba

File tree

6 files changed

+112
-4
lines changed

6 files changed

+112
-4
lines changed

.goreleaser.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ nfpms:
2828
license: MIT License
2929
formats:
3030
- deb
31+
recommends:
32+
- python3
33+
- nodejs
34+
- npm
35+
- php
36+
- python3-requests
37+
scripts:
38+
postinstall: "debian/postinstall.sh"
39+
preremove: "debian/preremove.sh"
40+
empty_folders:
41+
- /var/trusted-cgi
42+
- /etc/trusted-cgi
43+
files:
44+
"debian/trusted-cgi.service": "/etc/systemd/system/trusted-cgi.service"
45+
"debian/trusted-cgi.env": "/etc/trusted-cgi/trusted-cgi.env"
3146
uploads:
3247
- name: bintray
3348
method: PUT

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,31 @@ Add nice logo, license everything under MIT and you will get Trusted-CGI.
4343

4444
# Installation
4545

46-
## Direct to server
46+
## Play locally
4747

48-
Recommended: ubuntu LTS x64 server
48+
Just download and run `trusted-cgi --dev`
49+
50+
## Direct to server (recommended)
4951

50-
Please see in bintray or in [releases](https://github.com/reddec/trusted-cgi/releases) page
52+
Recommended: ubuntu LTS x64 server
5153

54+
0. Add bintray key `sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61`
55+
1. Download from [releases](https://github.com/reddec/trusted-cgi/releases) page, or (better) use bintray repo
5256
[![Download](https://api.bintray.com/packages/reddec/debian/trusted-cgi/images/download.svg)](https://bintray.com/reddec/debian/trusted-cgi/_latestVersion)
57+
2. `apt update` - update repos (optional since 18.04 and you used bintray repo)
58+
3. `apt install trusted-cgi` or for minimal `apt install --no-install-recommends trusted-cgi`
59+
60+
For Ubuntu 18.04
61+
62+
```bash
63+
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
64+
echo "deb https://dl.bintray.com/reddec/debian bionic main" | sudo tee -a /etc/apt/sources.list
65+
sudo apt install trusted-cgi
66+
```
5367

68+
Configuration files will be placed under `/etc/trusted-cgi`, functions files under `/var/trusted-cgi`,
69+
systemd service will be launched as `trusted-cgi` and all new services will be run under `trusted-cgi` system
70+
user.
5471

5572
## Docker
5673

@@ -74,6 +91,5 @@ make embed_ui
7491
7592
## TODO
7693
77-
* Service file for Ubuntu + user generation for chroot
7894
* Upload/download tarball
7995
* CLI control

debian/postinstall.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
CHROOT_USER="trusted-cgi"
4+
5+
if ! id -u ${CHROOT_USER}; then
6+
echo "Creating chroot user ${CHROOT_USER}..."
7+
useradd -M -c "trusted cgi dummy user" -r -s /bin/nologin ${CHROOT_USER}
8+
fi
9+
10+
systemctl enable trusted-cgi.service || echo "failed to enable service"
11+
systemctl start trusted-cgi.service || echo "failed to start service"

debian/preremove.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
CHROOT_USER="trusted-cgi"
4+
5+
systemctl stop trusted-cgi.service || echo "failed to stop service"
6+
systemctl disable trusted-cgi.service || echo "failed to disable service"
7+
8+
if id -u ${CHROOT_USER}; then
9+
echo "Removing user ${CHROOT_USER}..."
10+
userdel -r ${CHROOT_USER}
11+
fi
12+
13+

debian/trusted-cgi.env

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# HTTP binding location
2+
BIND=0.0.0.0:3434
3+
4+
# Timeout for graceful shutdown for HTTP server
5+
GRACEFUL_SHUTDOWN=15s
6+
7+
# Path to configuration file for server settings (will be created automatically if not found)
8+
CONFIG=/etc/trusted-cgi/server.json
9+
10+
# Location for services definition
11+
DIR=/var/trusted-cgi
12+
13+
# Location for templates definition
14+
TEMPLATES=/var/trusted-cgi/.templates
15+
16+
# Initial admin password (empty is autogenerated), could be changed over UI
17+
INITIAL_ADMIN_PASSWORD=admin
18+
19+
# Default user for services, could be changed over UI
20+
INITIAL_CHROOT_USER=trusted-cgi
21+
22+
# Disable chroot for new process (unsafe, but good for debugging)
23+
#DISABLE_CHROOT=true
24+
25+
# File for statistics dump
26+
STATS_FILE=/var/trusted-cgi/.stats
27+
28+
# Size for caching statistics (hits)
29+
STATS_CACHE=8192
30+
31+
# Statistics dump interval (in case of un-graceful termination data between dump will be lost)
32+
STATS_INTERVAL=30s
33+
34+
# Enable TLS
35+
#TLS=true
36+
37+
# Path to certificate for TLS
38+
#CERT_FILE=/etc/trusted-cgi/server.crt
39+
40+
# Path to private key for TLS
41+
#KEY_FILE=/etc/trusted-cgi/server.key

debian/trusted-cgi.service

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=Lightweight self-hosted serverless-functions engine
3+
4+
[Service]
5+
ExecStart=/usr/local/bin/trusted-cgi
6+
EnvironmentFile=/etc/trusted-cgi/trusted-cgi.env
7+
Restart=always
8+
RestartSec=3
9+
WorkingDirectory=/var/trusted-cgi
10+
11+
[Install]
12+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)