This commit is contained in:
Daniel Kukula 2025-08-10 19:19:19 +02:00
parent c7c5fa582c
commit 4469a6e6df
4 changed files with 244 additions and 0 deletions

6
ct/headers/livebook Normal file
View File

@ -0,0 +1,6 @@
__ _ __ __
/ / (_) _____ / /_ ____ ____ / /__
/ / / / | / / _ \/ __ \/ __ \/ __ \/ //_/
/ /___/ /| |/ / __/ /_/ / /_/ / /_/ / ,<
/_____/_/ |___/\___/_.___/\____/\____/_/|_|

55
ct/livebook.sh Executable file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env bash
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: dkuku
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/community-scripts/ProxmoxVE
APP="Livebook"
var_tags="${var_tags:-development}"
var_disk="${var_disk:-4}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-1024}"
var_os="${var_os:-debian}"
var_version="${var_version:-12}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /home/livebook ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
msg_info "Updating ${APP} LXC"
sudo -u livebook bash << 'EOF'
export HOME=/home/livebook
cd /home/livebook
source ~/.bashrc
mix local.hex --force >/dev/null 2>&1
mix local.rebar --force >/dev/null 2>&1
mix escript.install hex livebook --force >/dev/null 2>&1
EOF
msg_ok "Updated Successfully"
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}"
echo -e "${INFO}${YW} Authentication:${CL}"
echo -e "${TAB}${RD}• Token authentication enabled by default${CL}"
echo -e "${TAB}${RD}• Token will be shown in logs: journalctl -u livebook.service${CL}"
echo -e "${TAB}${RD}• Generated token: /data/token.txt${CL}"
echo -e "${TAB}${RD}• Configuration: /data/.env${CL}"

View File

@ -0,0 +1,42 @@
{
"name": "Livebook",
"slug": "livebook",
"categories": [
8
],
"date_created": "2025-08-10",
"type": "ct",
"updateable": true,
"privileged": false,
"config_path": "/data/.env",
"interface_port": 8080,
"documentation": "https://livebook.dev/",
"website": "https://livebook.dev/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/svg/livebook.svg",
"description": "Livebook is a web application for writing interactive and collaborative code notebooks for Elixir.",
"install_methods": [
{
"type": "default",
"script": "ct/livebook.sh",
"resources": {
"cpu": 2,
"ram": 1024,
"hdd": 4,
"os": "Debian",
"version": "12"
}
}
],
"default_credentials": {
"username": null,
"password": "Check /data/token.txt"
},
"notes": [
"Access token is stored in /data/token.txt",
"Default port is 8080",
"Working directory is /data",
"Home directory is /home/livebook",
"Elixir runtime with Mix.install/2 support",
"Service runs as livebook user"
]
}

141
install/livebook-install.sh Normal file
View File

@ -0,0 +1,141 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: dkuku
# License: MIT |
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies (matching Livebook Dockerfile)"
$STD apt-get install --no-install-recommends -y \
build-essential \
ca-certificates \
libncurses5-dev \
git \
wget \
cmake \
elixir
msg_ok "Installed Dependencies"
msg_info "Creating Livebook User and Directories"
useradd -r -s /bin/bash -d /home/livebook livebook
mkdir -p /home/livebook /data
chown livebook:livebook /home/livebook /data
# Make sure user has permissions to home dir (for Mix.install/2 cache)
chmod 777 /home/livebook
msg_ok "Created Livebook User and Directories"
msg_info "Installing Livebook"
sudo -u livebook bash << 'EOF'
export HOME=/home/livebook
cd /home/livebook
# Install hex and rebar for Mix.install/2 and Mix runtime (matching Dockerfile)
mix local.hex --force
mix local.rebar --force
# Following official Livebook escript installation instructions
mix escript.install hex livebook
echo 'export PATH="$HOME/.mix/escripts:$PATH"' >> ~/.bashrc
source ~/.bashrc
EOF
msg_ok "Installed Livebook"
msg_info "Creating Livebook Service"
cat <<EOF >/etc/systemd/system/livebook.service
[Unit]
Description=Livebook
After=network.target
[Service]
Type=exec
User=livebook
Group=livebook
WorkingDirectory=/data
Environment=HOME=/home/livebook
Environment=PATH=/home/livebook/.mix/escripts:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Environment=LIVEBOOK_PORT=8080
Environment=LIVEBOOK_IP="::"
Environment=LIVEBOOK_HOME=/data
ExecStart=/home/livebook/.mix/escripts/livebook server
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable livebook.service
msg_ok "Created Livebook Service"
msg_info "Setting up Authentication"
# Generate a secure token for authentication
TOKEN=$(openssl rand -hex 32)
sudo -u livebook bash << EOF
cd /home/livebook
export HOME=/home/livebook
export PATH="\$HOME/.mix/escripts:\$PATH"
# Create environment file with authentication settings
cat > /data/.env << 'ENVEOF'
# Livebook Authentication Configuration
# Uncomment one of the following options:
# Option 1: Password authentication (recommended for production)
# LIVEBOOK_PASSWORD=$TOKEN
# Option 2: Token authentication (default - token will be shown in logs)
# LIVEBOOK_TOKEN_ENABLED=true
# Option 3: Disable authentication (NOT recommended for production)
# LIVEBOOK_TOKEN_ENABLED=false
# Current setting: Token authentication (default)
LIVEBOOK_TOKEN_ENABLED=true
ENVEOF
# Save the token for easy access
echo "$TOKEN" > /data/token.txt
chmod 600 /data/token.txt
chown livebook:livebook /data/.env /data/token.txt
EOF
msg_ok "Set up Authentication"
msg_info "Starting Livebook Service"
systemctl start livebook.service
msg_ok "Started Livebook Service"
msg_info "Cleaning Up"
rm -f /tmp/erlang-solutions_2.0_all.deb
$STD apt-get autoremove -y
$STD apt-get autoclean
msg_ok "Cleaned Up"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
echo -e "\n${CREATING}${GN}Livebook Installation Complete!${CL}\n"
echo -e "${INFO}${YW}Authentication Information:${CL}"
echo -e "${TAB}${RD}• Default: Token authentication (auto-generated)${CL}"
echo -e "${TAB}${RD}• Token will be displayed in Livebook logs on startup${CL}"
echo -e "${TAB}${RD}• Generated token saved to: /data/token.txt${CL}"
echo -e "${TAB}${RD}• Configuration file: /data/.env${CL}\n"
echo -e "${INFO}${YW}To configure authentication:${CL}"
echo -e "${TAB}${RD}1. Password auth: Edit /data/.env and uncomment LIVEBOOK_PASSWORD${CL}"
echo -e "${TAB}${RD}2. No auth: Edit /data/.env and set LIVEBOOK_TOKEN_ENABLED=false${CL}"
echo -e "${TAB}${RD}3. Restart service: systemctl restart livebook.service${CL}\n"
echo -e "${INFO}${YW}Generated Token (for reference):${CL}"
echo -e "${TAB}${GN}$(cat /data/token.txt)${CL}\n"