Skip to content

Commit 7f5ee39

Browse files
New Script: Privatebin (#1925)
* Create privatebin-install.sh * Create privatebin.sh * Create privatebin.json * Update ct/privatebin.sh Co-authored-by: Michel Roegl-Brunner <[email protected]> * Update install/privatebin-install.sh Co-authored-by: Michel Roegl-Brunner <[email protected]> * Update install/privatebin-install.sh Co-authored-by: Michel Roegl-Brunner <[email protected]> * Update install/privatebin-install.sh Co-authored-by: Michel Roegl-Brunner <[email protected]> * Update ct/privatebin.sh Co-authored-by: Michel Roegl-Brunner <[email protected]> --------- Co-authored-by: Michel Roegl-Brunner <[email protected]>
1 parent 8533321 commit 7f5ee39

File tree

3 files changed

+208
-0
lines changed

3 files changed

+208
-0
lines changed

ct/privatebin.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
4+
# Copyright (c) 2021-2025 community-scripts ORG
5+
# Author: Nícolas Pastorello (opastorello)
6+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
7+
8+
# App Default Values
9+
APP="PrivateBin"
10+
var_tags="paste;secure"
11+
var_cpu="1"
12+
var_ram="1024"
13+
var_disk="4"
14+
var_os="debian"
15+
var_version="12"
16+
var_unprivileged="1"
17+
18+
# App Output & Base Settings
19+
header_info "$APP"
20+
base_settings
21+
22+
# Core
23+
variables
24+
color
25+
catch_errors
26+
27+
function update_script() {
28+
header_info
29+
check_container_storage
30+
check_container_resources
31+
if [[ ! -d /opt/privatebin ]]; then
32+
msg_error "No ${APP} Installation Found!"
33+
exit
34+
fi
35+
RELEASE=$(curl -s https://api.github.com/repos/PrivateBin/PrivateBin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
36+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
37+
msg_info "Updating ${APP} to v${RELEASE}"
38+
echo "${RELEASE}" >/opt/${APP}_version.txt
39+
cp -f /opt/privatebin/cfg/conf.php /tmp/privatebin_conf.bak
40+
wget -q "https://github.com/PrivateBin/PrivateBin/archive/refs/tags/${RELEASE}.zip"
41+
unzip -q ${RELEASE}.zip
42+
rm -rf /opt/privatebin/*
43+
mv PrivateBin-${RELEASE}/* /opt/privatebin/
44+
mv /tmp/privatebin_conf.bak /opt/privatebin/cfg/conf.php
45+
chown -R www-data:www-data /opt/privatebin
46+
chmod -R 0755 /opt/privatebin/data
47+
echo "${RELEASE}" >/opt/${APP}_version.txt
48+
rm -rf ${RELEASE}.zip PrivateBin-${RELEASE}
49+
systemctl reload nginx php8.2-fpm
50+
msg_ok "Updated ${APP} to v${RELEASE}"
51+
else
52+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
53+
fi
54+
exit
55+
}
56+
57+
start
58+
build_container
59+
description
60+
61+
msg_ok "Completed Successfully!\n"
62+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
63+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
64+
echo -e "${TAB}${GATEWAY}${BGN}https://${IP}${CL}"

install/privatebin-install.sh

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Nícolas Pastorello (opastorello)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
7+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
8+
color
9+
verb_ip6
10+
catch_errors
11+
setting_up_container
12+
network_check
13+
update_os
14+
15+
msg_info "Installing Dependencies"
16+
$STD apt-get install -y \
17+
curl \
18+
sudo \
19+
mc \
20+
nginx \
21+
php8.2-fpm \
22+
php8.2-{common,cli,gd,mbstring,xml,fpm,curl,zip} \
23+
unzip \
24+
openssl
25+
msg_ok "Installed Dependencies"
26+
27+
msg_info "Installing PrivateBin"
28+
RELEASE=$(curl -s https://api.github.com/repos/PrivateBin/PrivateBin/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
29+
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
30+
mkdir -p /opt/privatebin
31+
cd /opt/privatebin
32+
wget -q "https://github.com/PrivateBin/PrivateBin/archive/refs/tags/${RELEASE}.zip"
33+
$STD unzip -q ${RELEASE}.zip
34+
mv PrivateBin-${RELEASE}/* .
35+
msg_ok "Installed PrivateBin"
36+
37+
msg_info "Generating Universal SSL Certificate"
38+
mkdir -p /etc/ssl/privatebin
39+
$STD openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
40+
-keyout /etc/ssl/privatebin/key.pem \
41+
-out /etc/ssl/privatebin/cert.pem \
42+
-subj "/CN=PrivateBin"
43+
msg_ok "Certificate Generated"
44+
45+
msg_info "Configuring Environment"
46+
mkdir -p /opt/privatebin/data
47+
cp cfg/conf.sample.php /opt/privatebin/cfg/conf.php
48+
sed -i "s|// 'traffic'|'traffic'|g" /opt/privatebin/cfg/conf.php
49+
chown -R www-data:www-data /opt/privatebin
50+
chmod -R 0755 /opt/privatebin/data
51+
msg_ok "Configured Environment"
52+
53+
msg_info "Configuring PHP"
54+
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/8.2/fpm/php.ini
55+
systemctl restart php8.2-fpm
56+
msg_ok "Configured PHP"
57+
58+
msg_info "Configuring Universal Nginx"
59+
cat <<EOF >/etc/nginx/sites-available/privatebin.conf
60+
server {
61+
listen 80 default_server;
62+
listen [::]:80 default_server;
63+
return 301 https://\$host\$request_uri;
64+
}
65+
66+
server {
67+
listen 443 ssl default_server;
68+
listen [::]:443 ssl default_server;
69+
70+
ssl_certificate /etc/ssl/privatebin/cert.pem;
71+
ssl_certificate_key /etc/ssl/privatebin/key.pem;
72+
73+
root /opt/privatebin;
74+
index index.php;
75+
76+
location / {
77+
try_files \$uri \$uri/ /index.php\$is_args\$args;
78+
}
79+
80+
location ~ \.php\$ {
81+
include snippets/fastcgi-php.conf;
82+
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
83+
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
84+
include fastcgi_params;
85+
}
86+
87+
location ~ /\.ht {
88+
deny all;
89+
}
90+
91+
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
92+
add_header X-Content-Type-Options nosniff;
93+
add_header X-Frame-Options "SAMEORIGIN";
94+
add_header X-XSS-Protection "1; mode=block";
95+
}
96+
EOF
97+
ln -s /etc/nginx/sites-available/privatebin.conf /etc/nginx/sites-enabled/
98+
rm -f /etc/nginx/sites-enabled/default
99+
systemctl reload nginx
100+
msg_ok "Nginx Configured"
101+
102+
msg_info "Cleaning up"
103+
rm -rf /opt/privatebin/${RELEASE}.zip
104+
rm -rf /opt/privatebin/PrivateBin-${RELEASE}
105+
$STD apt-get -y autoremove
106+
$STD apt-get -y autoclean
107+
msg_ok "Cleaned"
108+
109+
motd_ssh
110+
customize

json/privatebin.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "PrivateBin",
3+
"slug": "privatebin",
4+
"categories": [
5+
12
6+
],
7+
"date_created": "2025-01-29",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 80,
12+
"documentation": "https://github.com/PrivateBin/PrivateBin/wiki",
13+
"website": "https://github.com/PrivateBin/PrivateBin",
14+
"logo": "https://raw.githubusercontent.com/PrivateBin/PrivateBin/refs/heads/master/img/icon.svg",
15+
"description": "PrivateBin is a minimalist, open-source pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256-bit AES.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "ct/privatebin.sh",
20+
"resources": {
21+
"cpu": 1,
22+
"ram": 1024,
23+
"hdd": 4,
24+
"os": "debian",
25+
"version": "12"
26+
}
27+
}
28+
],
29+
"default_credentials": {
30+
"username": null,
31+
"password": null
32+
},
33+
"notes": []
34+
}

0 commit comments

Comments
 (0)