From 4469a6e6df45aecdbc4e046e51d66bcff0c554ac Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 10 Aug 2025 19:19:19 +0200 Subject: [PATCH 01/24] livebook --- ct/headers/livebook | 6 ++ ct/livebook.sh | 55 +++++++++++ frontend/public/json/livebook.json | 42 +++++++++ install/livebook-install.sh | 141 +++++++++++++++++++++++++++++ 4 files changed, 244 insertions(+) create mode 100644 ct/headers/livebook create mode 100755 ct/livebook.sh create mode 100644 frontend/public/json/livebook.json create mode 100644 install/livebook-install.sh diff --git a/ct/headers/livebook b/ct/headers/livebook new file mode 100644 index 00000000..7b50abfd --- /dev/null +++ b/ct/headers/livebook @@ -0,0 +1,6 @@ + __ _ __ __ + / / (_) _____ / /_ ____ ____ / /__ + / / / / | / / _ \/ __ \/ __ \/ __ \/ //_/ + / /___/ /| |/ / __/ /_/ / /_/ / /_/ / ,< +/_____/_/ |___/\___/_.___/\____/\____/_/|_| + diff --git a/ct/livebook.sh b/ct/livebook.sh new file mode 100755 index 00000000..bcc35e3c --- /dev/null +++ b/ct/livebook.sh @@ -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}" diff --git a/frontend/public/json/livebook.json b/frontend/public/json/livebook.json new file mode 100644 index 00000000..155d1690 --- /dev/null +++ b/frontend/public/json/livebook.json @@ -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" + ] +} diff --git a/install/livebook-install.sh b/install/livebook-install.sh new file mode 100644 index 00000000..61f96b92 --- /dev/null +++ b/install/livebook-install.sh @@ -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 </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" From ddf32895dcefa34058cb74b99feb713560a18659 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Tue, 12 Aug 2025 21:39:42 +0200 Subject: [PATCH 02/24] livebook --- ct/livebook.sh | 97 +++++++++++----- frontend/public/json/livebook.json | 4 +- install/livebook-install.sh | 171 +++++++++++++++-------------- misc/build.func | 2 +- misc/install.func | 2 +- 5 files changed, 163 insertions(+), 113 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index bcc35e3c..177db87f 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,17 +1,17 @@ #!/usr/bin/env bash -source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/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 +# Source: https://github.com/livebook-dev/livebook 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_os="${var_os:-ubuntu}" +var_version="${var_version:-24}" var_unprivileged="${var_unprivileged:-1}" header_info "$APP" @@ -20,24 +20,69 @@ 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 + header_info + check_container_storage + check_container_resources + + # Check if Livebook is installed + if [[ ! -d /opt/${APP}_version.txt ]]; then + msg_error "No ${APP} Installation Found!" + exit 1 + fi + + # Get the latest version from GitHub + msg_info "Checking for updates..." + RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') + + if [[ -z "$RELEASE" ]]; then + msg_error "Failed to fetch latest version information" + exit 1 + fi + + # Check if version file exists and compare versions + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then + msg_info "Updating ${APP} to v${RELEASE}" + + # Create backup of user data if it exists + if [[ -d /home/livebook ]]; then + msg_info "Creating backup of user data..." + $STD cp -r /home/livebook /home/livebook-backup 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 + + # Perform the update + msg_info "Installing dependencies and updating Livebook..." + if ! sudo -u livebook bash -c ' + export HOME=/home/livebook + cd /home/livebook + 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 + '; then + msg_error "Failed to update Livebook" + # Restore from backup if update failed + if [[ -d /home/livebook-backup ]]; then + msg_info "Restoring from backup..." + rm -rf /home/livebook + mv /home/livebook-backup /home/livebook + fi + exit 1 + fi + + # Save the new version + echo "$RELEASE" | $STD tee /opt/${APP}_version.txt >/dev/null + + # Cleanup backup if update was successful + if [[ -d /home/livebook-backup ]]; then + msg_info "Cleaning up backup..." + $STD rm -rf /home/livebook-backup + fi + + msg_ok "Successfully updated to v${RELEASE}" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}." + fi + + exit } start @@ -47,9 +92,7 @@ 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}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}" +echo -e "\n${INFO}${YW} To start Livebook, run the following command:${CL}" +echo -e "${TAB}${BGN}sudo -u livebook /root/.mix/escripts/livebook server${CL}" +echo -e "\n${INFO}${YW} To run it as a service, create a systemd service file.${CL}" diff --git a/frontend/public/json/livebook.json b/frontend/public/json/livebook.json index 155d1690..432a0617 100644 --- a/frontend/public/json/livebook.json +++ b/frontend/public/json/livebook.json @@ -22,8 +22,8 @@ "cpu": 2, "ram": 1024, "hdd": 4, - "os": "Debian", - "version": "12" + "os": "Ubuntu", + "version": "24" } } ], diff --git a/install/livebook-install.sh b/install/livebook-install.sh index 61f96b92..eacc992b 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -2,7 +2,8 @@ # Copyright (c) 2021-2025 community-scripts ORG # Author: dkuku -# License: MIT | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/livebook-dev/livebook source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" color @@ -16,34 +17,88 @@ 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 + curl \ + git \ + libncurses5-dev 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 +useradd -r -s /bin/bash -d /opt livebook +mkdir -p /opt /data +chown livebook:livebook /opt /data + +chmod 777 /opt 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 +msg_info "Installing Erlang and Elixir" +# Create a temporary script +cat > /tmp/setup_elixir.sh << 'EOF' +#!/bin/bash +export HOME=/opt +cd /opt +curl -fsSO https://elixir-lang.org/install.sh +sh install.sh elixir@1.18.4 otp@27.3.4 >/dev/null 2>&1 + +# Create .env if it doesn't exist and set permissions +touch $HOME/.env +chmod 644 $HOME/.env + +# Add exports to .env +echo 'export HOME=/opt' >> $HOME/.env +echo 'export PATH="$HOME/.elixir-install/installs/otp/27.3.4/bin:$HOME/.elixir-install/installs/elixir/1.18.4-otp-27/bin:$PATH"' >> $HOME/.env EOF -msg_ok "Installed Livebook" + +# Make it executable and run as livebook user +chmod +x /tmp/setup_elixir.sh +$STD sudo -u livebook -H /tmp/setup_elixir.sh +rm /tmp/setup_elixir.sh +msg_ok "Installed Erlang 27.3.4 and Elixir 1.18.4" + +msg_info "Installing Livebook" + +cat > /tmp/install_livebook.sh << 'EOF' +#!/bin/bash +RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') +echo "${RELEASE}" >/opt/Livebook_version.txt + +set -e # Exit on any error +source /opt/.env +cd $HOME + +# Install hex and rebar for Mix.install/2 and Mix runtime (matching Dockerfile) +echo "Installing hex..." +mix local.hex --force +echo "Installing rebar..." +mix local.rebar --force + +# Following official Livebook escript installation instructions +echo "Installing Livebook escript..." +MIX_ENV=prod mix escript.install hex livebook --force + +# Add escripts to PATH +echo 'export PATH="$HOME/.mix/escripts:$PATH"' >> ~/.env + +# Verify livebook was installed and make executable +if [ -f ~/.mix/escripts/livebook ]; then + chmod +x ~/.mix/escripts/livebook + echo "Livebook escript installed successfully" + ls -la ~/.mix/escripts/livebook +else + echo "ERROR: Livebook escript not found after installation" + ls -la ~/.mix/escripts/ || echo "No escripts directory found" + # Try to show what went wrong + echo "Mix environment:" + mix --version + echo "Available packages:" + mix hex.info livebook || echo "Could not get livebook info" + exit 1 +fi +EOF + +chmod +x /tmp/install_livebook.sh +$STD sudo -u livebook -H /tmp/install_livebook.sh +rm /tmp/install_livebook.sh msg_info "Creating Livebook Service" cat </etc/systemd/system/livebook.service @@ -56,12 +111,14 @@ 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=MIX_ENV=prod +Environment=HOME=/opt +Environment=PATH=/opt/.mix/escripts:/opt/.elixir-install/installs/otp/27.3.4/bin:/opt/.elixir-install/installs/elixir/1.18.4-otp-27/bin:/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 +Environment=LIVEBOOK_TOKEN_ENABLED=false +ExecStart=/bin/bash -c 'cd /opt && livebook server' Restart=always RestartSec=5 StandardOutput=journal @@ -71,71 +128,21 @@ StandardError=journal WantedBy=multi-user.target EOF -systemctl daemon-reload -systemctl enable livebook.service +$STD 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 +rm -f /opt/install.sh $STD apt-get autoremove -y $STD apt-get autoclean msg_ok "Cleaned Up" +msg_info "Starting Livebook Service" +$STD systemctl start livebook.service +msg_ok "Started Livebook Service" + + 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" diff --git a/misc/build.func b/misc/build.func index c40a57bd..49b20b7f 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1438,7 +1438,7 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index e3751c29..48c196cf 100644 --- a/misc/install.func +++ b/misc/install.func @@ -31,7 +31,7 @@ catch_errors() { # This function handles errors error_handler() { - source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) + source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/api.func) printf "\e[?25h" local exit_code="$?" local line_number="$1" From b6db98b8dc1ec8667924ac6b94aaa6c214afbd6d Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Wed, 13 Aug 2025 19:49:06 +0200 Subject: [PATCH 03/24] update logic --- ct/livebook.sh | 49 ++--- frontend/public/json/livebook.json | 7 +- install.sh | 298 +++++++++++++++++++++++++++++ install/livebook-install.sh | 81 ++------ misc/build.func | 14 +- misc/install.func | 6 +- 6 files changed, 338 insertions(+), 117 deletions(-) create mode 100755 install.sh diff --git a/ct/livebook.sh b/ct/livebook.sh index 177db87f..2899724d 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -5,6 +5,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/head # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://github.com/livebook-dev/livebook +echo -e "Loading..." APP="Livebook" var_tags="${var_tags:-development}" var_disk="${var_disk:-4}" @@ -25,7 +26,7 @@ function update_script() { check_container_resources # Check if Livebook is installed - if [[ ! -d /opt/${APP}_version.txt ]]; then + if [[ ! -f /opt/${APP}_version.txt ]]; then msg_error "No ${APP} Installation Found!" exit 1 fi @@ -40,41 +41,24 @@ function update_script() { fi # Check if version file exists and compare versions - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then - msg_info "Updating ${APP} to v${RELEASE}" + if [[ "${RELEASE}" == "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then + #if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then + msg_info "Updating ${APP} LXC" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated ${APP} LXC" - # Create backup of user data if it exists - if [[ -d /home/livebook ]]; then - msg_info "Creating backup of user data..." - $STD cp -r /home/livebook /home/livebook-backup - fi - - # Perform the update - msg_info "Installing dependencies and updating Livebook..." - if ! sudo -u livebook bash -c ' - export HOME=/home/livebook - cd /home/livebook - 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 - '; then - msg_error "Failed to update Livebook" - # Restore from backup if update failed - if [[ -d /home/livebook-backup ]]; then - msg_info "Restoring from backup..." - rm -rf /home/livebook - mv /home/livebook-backup /home/livebook - fi - exit 1 - fi + msg_info "Updating ${APP} to ${RELEASE}" + source /opt/.env + cd /opt || exit 1 + mix escript.install hex livebook --force >/dev/null 2>&1 # Save the new version echo "$RELEASE" | $STD tee /opt/${APP}_version.txt >/dev/null # Cleanup backup if update was successful - if [[ -d /home/livebook-backup ]]; then - msg_info "Cleaning up backup..." - $STD rm -rf /home/livebook-backup + if [[ -d /opt-backup ]]; then + $STD rm -rf /opt-backup fi msg_ok "Successfully updated to v${RELEASE}" @@ -92,7 +76,4 @@ 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}${CL}" -echo -e "\n${INFO}${YW} To start Livebook, run the following command:${CL}" -echo -e "${TAB}${BGN}sudo -u livebook /root/.mix/escripts/livebook server${CL}" -echo -e "\n${INFO}${YW} To run it as a service, create a systemd service file.${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}" diff --git a/frontend/public/json/livebook.json b/frontend/public/json/livebook.json index 432a0617..f5599d2b 100644 --- a/frontend/public/json/livebook.json +++ b/frontend/public/json/livebook.json @@ -29,14 +29,13 @@ ], "default_credentials": { "username": null, - "password": "Check /data/token.txt" + "password": null }, "notes": [ - "Access token is stored in /data/token.txt", "Default port is 8080", "Working directory is /data", - "Home directory is /home/livebook", + "Home directory is /opt", "Elixir runtime with Mix.install/2 support", - "Service runs as livebook user" + "Service runs as root user" ] } diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..f1647a15 --- /dev/null +++ b/install.sh @@ -0,0 +1,298 @@ +#!/bin/sh +# See latest version at: +# https://github.com/elixir-lang/elixir-lang.github.com/blob/main/install.sh + +set -eu + +otp_version= +elixir_version= +force=false + +usage() { + cat<&2 + exit 1 + ;; + esac + done + + if [ -z "${elixir_version}" ]; then + usage + echo "error: missing elixir@VERSION argument" + exit 1 + fi + + if [ -z "${otp_version}" ]; then + usage + echo "error: missing otp@VERSION argument" + exit 1 + fi + + root_dir="$HOME/.elixir-install" + tmp_dir="$root_dir/tmp" + mkdir -p "$tmp_dir" + + if [ "${otp_version}" = latest ]; then + url=$(curl -fsS --head https://github.com/erlef/otp_builds/releases/latest | grep -i '^location:' | awk '{print $2}' | tr -d '\r\n') + tag=$(basename "$url") + otp_version="${tag#OTP-}" + fi + + if [ "${elixir_version}" = latest ]; then + url=$(curl -fsS --head https://github.com/elixir-lang/elixir/releases/latest | grep -i '^location:' | awk '{print $2}' | tr -d '\r\n') + tag=$(basename "$url") + elixir_version="${tag#v}" + fi + + case "${otp_version}" in + master|maint*) + branch_version=$(curl -fsS https://raw.githubusercontent.com/erlang/otp/refs/heads/${otp_version}/OTP_VERSION | tr -d '\n') + elixir_otp_release="${branch_version%%.*}" + ;; + *) + elixir_otp_release="${otp_version%%.*}" + ;; + esac + + case "$elixir_version" in + 1.14.*) + [ "${elixir_otp_release}" -ge 25 ] && elixir_otp_release=25 + ;; + 1.15.*|1.16.*) + [ "${elixir_otp_release}" -ge 26 ] && elixir_otp_release=26 + ;; + 1.17.*|1.18.*) + [ "${elixir_otp_release}" -ge 27 ] && elixir_otp_release=27 + ;; + 1.19.*) + [ "${elixir_otp_release}" -ge 28 ] && elixir_otp_release=28 + ;; + *) + [ "${elixir_otp_release}" -ge 28 ] && elixir_otp_release=28 + ;; + esac + + otp_dir="$root_dir/installs/otp/$otp_version" + elixir_dir="${root_dir}/installs/elixir/${elixir_version}-otp-${elixir_otp_release}" + + if unzip_available; then + install_otp & + pid_otp=$! + + install_elixir & + pid_elixir=$! + + wait $pid_otp + wait $pid_elixir + else + # if unzip is missing (e.g. official docker ubuntu image), install otp and elixir + # serially because we unzip elixir using OTP zip:extract/2. + install_otp + install_elixir + fi + + printf "checking OTP... " + export PATH="$otp_dir/bin:$PATH" + erl -noshell -eval 'io:put_chars(erlang:system_info(otp_release) ++ " ok\n"), halt().' + + printf "checking Elixir... " + "$elixir_dir/bin/elixir" -e 'IO.puts(System.version() <> " ok")' + + export PATH="$elixir_dir/bin:$PATH" +cat</dev/null 2>&1 +} + +main "$@" diff --git a/install/livebook-install.sh b/install/livebook-install.sh index eacc992b..20ae054e 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -23,82 +23,29 @@ $STD apt-get install --no-install-recommends -y \ libncurses5-dev msg_ok "Installed Dependencies" -msg_info "Creating Livebook User and Directories" -useradd -r -s /bin/bash -d /opt livebook -mkdir -p /opt /data -chown livebook:livebook /opt /data - -chmod 777 /opt -msg_ok "Created Livebook User and Directories" msg_info "Installing Erlang and Elixir" -# Create a temporary script -cat > /tmp/setup_elixir.sh << 'EOF' -#!/bin/bash +mkdir -p /opt /data export HOME=/opt -cd /opt +touch $HOME/.env +cd /opt || exit 1 curl -fsSO https://elixir-lang.org/install.sh sh install.sh elixir@1.18.4 otp@27.3.4 >/dev/null 2>&1 - -# Create .env if it doesn't exist and set permissions -touch $HOME/.env -chmod 644 $HOME/.env - -# Add exports to .env echo 'export HOME=/opt' >> $HOME/.env -echo 'export PATH="$HOME/.elixir-install/installs/otp/27.3.4/bin:$HOME/.elixir-install/installs/elixir/1.18.4-otp-27/bin:$PATH"' >> $HOME/.env -EOF - -# Make it executable and run as livebook user -chmod +x /tmp/setup_elixir.sh -$STD sudo -u livebook -H /tmp/setup_elixir.sh -rm /tmp/setup_elixir.sh +echo 'export PATH="/opt/.elixir-install/installs/otp/27.3.4/bin:/opt/.elixir-install/installs/elixir/1.18.4-otp-27/bin:$PATH"' >> $HOME/.env msg_ok "Installed Erlang 27.3.4 and Elixir 1.18.4" msg_info "Installing Livebook" - -cat > /tmp/install_livebook.sh << 'EOF' -#!/bin/bash RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') echo "${RELEASE}" >/opt/Livebook_version.txt -set -e # Exit on any error source /opt/.env -cd $HOME - -# Install hex and rebar for Mix.install/2 and Mix runtime (matching Dockerfile) -echo "Installing hex..." -mix local.hex --force -echo "Installing rebar..." -mix local.rebar --force - -# Following official Livebook escript installation instructions -echo "Installing Livebook escript..." -MIX_ENV=prod mix escript.install hex livebook --force - -# Add escripts to PATH +cd /opt || exit 1 +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 echo 'export PATH="$HOME/.mix/escripts:$PATH"' >> ~/.env - -# Verify livebook was installed and make executable -if [ -f ~/.mix/escripts/livebook ]; then - chmod +x ~/.mix/escripts/livebook - echo "Livebook escript installed successfully" - ls -la ~/.mix/escripts/livebook -else - echo "ERROR: Livebook escript not found after installation" - ls -la ~/.mix/escripts/ || echo "No escripts directory found" - # Try to show what went wrong - echo "Mix environment:" - mix --version - echo "Available packages:" - mix hex.info livebook || echo "Could not get livebook info" - exit 1 -fi -EOF - -chmod +x /tmp/install_livebook.sh -$STD sudo -u livebook -H /tmp/install_livebook.sh -rm /tmp/install_livebook.sh +msg_ok "Installed Livebook" msg_info "Creating Livebook Service" cat </etc/systemd/system/livebook.service @@ -108,8 +55,8 @@ After=network.target [Service] Type=exec -User=livebook -Group=livebook +User=root +Group=root WorkingDirectory=/data Environment=MIX_ENV=prod Environment=HOME=/opt @@ -129,6 +76,7 @@ WantedBy=multi-user.target EOF $STD systemctl enable livebook.service +$STD systemctl start livebook.service msg_ok "Created Livebook Service" msg_info "Cleaning Up" @@ -137,11 +85,6 @@ $STD apt-get autoremove -y $STD apt-get autoclean msg_ok "Cleaned Up" -msg_info "Starting Livebook Service" -$STD systemctl start livebook.service -msg_ok "Started Livebook Service" - - motd_ssh customize diff --git a/misc/build.func b/misc/build.func index 49b20b7f..c03764f8 100644 --- a/misc/build.func +++ b/misc/build.func @@ -16,10 +16,10 @@ variables() { CT_TYPE=${var_unprivileged:-$CT_TYPE} } -source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/api.func) +source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/api.func) if command -v curl >/dev/null 2>&1; then - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) + source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/core.func) load_functions #echo "(build.func) Loaded core.func via curl" elif command -v wget >/dev/null 2>&1; then @@ -988,7 +988,7 @@ install_script() { header_info echo -e "${INFO}${HOLD} ${GN}Using Config File on node $PVEHOST_NAME${CL}" METHOD="advanced" - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/config-file.func) + source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/config-file.func) config_file ;; 5) @@ -1061,7 +1061,7 @@ check_container_storage() { } start() { - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/tools.func) + source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/tools.func) if command -v pveversion >/dev/null 2>&1; then install_script elif [ ! -z ${PHS_SILENT+x} ] && [[ "${PHS_SILENT}" == "1" ]]; then @@ -1127,9 +1127,9 @@ build_container() { TEMP_DIR=$(mktemp -d) pushd "$TEMP_DIR" >/dev/null if [ "$var_os" == "alpine" ]; then - export FUNCTIONS_FILE_PATH="$(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/alpine-install.func)" + export FUNCTIONS_FILE_PATH="$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/alpine-install.func)" else - export FUNCTIONS_FILE_PATH="$(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/install.func)" + export FUNCTIONS_FILE_PATH="$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/install.func)" fi export DIAGNOSTICS="$DIAGNOSTICS" export RANDOM_UUID="$RANDOM_UUID" @@ -1163,7 +1163,7 @@ build_container() { -unprivileged $CT_TYPE $PW " - bash -c "$(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/create_lxc.sh)" || exit + bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/create_lxc.sh)" || exit if [ $? -ne 0 ]; then exit 200 fi diff --git a/misc/install.func b/misc/install.func index 48c196cf..b38ff336 100644 --- a/misc/install.func +++ b/misc/install.func @@ -10,7 +10,7 @@ if ! command -v curl >/dev/null 2>&1; then apt-get update >/dev/null 2>&1 apt-get install -y curl >/dev/null 2>&1 fi -source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) +source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/core.func) load_functions # This function enables IPv6 if it's not disabled and sets verbose mode @@ -148,7 +148,7 @@ EOF $STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED msg_ok "Updated Container OS" - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/tools.func) + source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/tools.func) } # This function modifies the message of the day (motd) and SSH settings @@ -196,7 +196,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From 12d5850edec8610e9b56d0e9dbed5375612990df Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Wed, 13 Aug 2025 19:50:20 +0200 Subject: [PATCH 04/24] unused --- ct/livebook.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index 2899724d..79007951 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -56,11 +56,6 @@ function update_script() { # Save the new version echo "$RELEASE" | $STD tee /opt/${APP}_version.txt >/dev/null - # Cleanup backup if update was successful - if [[ -d /opt-backup ]]; then - $STD rm -rf /opt-backup - fi - msg_ok "Successfully updated to v${RELEASE}" else msg_ok "No update required. ${APP} is already at v${RELEASE}." From 31e3851909b91f4fa336d89b86a278f18ee6aff4 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Wed, 13 Aug 2025 20:00:59 +0200 Subject: [PATCH 05/24] switch to proper update --- ct/livebook.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index 79007951..81bc3e2a 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -41,8 +41,7 @@ function update_script() { fi # Check if version file exists and compare versions - if [[ "${RELEASE}" == "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then - #if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then msg_info "Updating ${APP} LXC" $STD apt-get update $STD apt-get -y upgrade @@ -51,14 +50,15 @@ function update_script() { msg_info "Updating ${APP} to ${RELEASE}" source /opt/.env cd /opt || exit 1 + rm /opt/.mix/escripts/livebook mix escript.install hex livebook --force >/dev/null 2>&1 # Save the new version echo "$RELEASE" | $STD tee /opt/${APP}_version.txt >/dev/null - msg_ok "Successfully updated to v${RELEASE}" + msg_ok "Successfully updated to ${RELEASE}" else - msg_ok "No update required. ${APP} is already at v${RELEASE}." + msg_ok "No update required. ${APP} is already at ${RELEASE}." fi exit From 9fb30f587f706e8abaa8b2f239e54538e0d563d2 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Wed, 13 Aug 2025 20:07:00 +0200 Subject: [PATCH 06/24] reset function --- misc/build.func | 16 ++++++++-------- misc/install.func | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/misc/build.func b/misc/build.func index c03764f8..c40a57bd 100644 --- a/misc/build.func +++ b/misc/build.func @@ -16,10 +16,10 @@ variables() { CT_TYPE=${var_unprivileged:-$CT_TYPE} } -source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/api.func) +source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/api.func) if command -v curl >/dev/null 2>&1; then - source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/core.func) + source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) load_functions #echo "(build.func) Loaded core.func via curl" elif command -v wget >/dev/null 2>&1; then @@ -988,7 +988,7 @@ install_script() { header_info echo -e "${INFO}${HOLD} ${GN}Using Config File on node $PVEHOST_NAME${CL}" METHOD="advanced" - source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/config-file.func) + source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/config-file.func) config_file ;; 5) @@ -1061,7 +1061,7 @@ check_container_storage() { } start() { - source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/tools.func) + source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/tools.func) if command -v pveversion >/dev/null 2>&1; then install_script elif [ ! -z ${PHS_SILENT+x} ] && [[ "${PHS_SILENT}" == "1" ]]; then @@ -1127,9 +1127,9 @@ build_container() { TEMP_DIR=$(mktemp -d) pushd "$TEMP_DIR" >/dev/null if [ "$var_os" == "alpine" ]; then - export FUNCTIONS_FILE_PATH="$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/alpine-install.func)" + export FUNCTIONS_FILE_PATH="$(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/alpine-install.func)" else - export FUNCTIONS_FILE_PATH="$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/install.func)" + export FUNCTIONS_FILE_PATH="$(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/install.func)" fi export DIAGNOSTICS="$DIAGNOSTICS" export RANDOM_UUID="$RANDOM_UUID" @@ -1163,7 +1163,7 @@ build_container() { -unprivileged $CT_TYPE $PW " - bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/create_lxc.sh)" || exit + bash -c "$(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/create_lxc.sh)" || exit if [ $? -ne 0 ]; then exit 200 fi @@ -1438,7 +1438,7 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index b38ff336..e3751c29 100644 --- a/misc/install.func +++ b/misc/install.func @@ -10,7 +10,7 @@ if ! command -v curl >/dev/null 2>&1; then apt-get update >/dev/null 2>&1 apt-get install -y curl >/dev/null 2>&1 fi -source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/core.func) +source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) load_functions # This function enables IPv6 if it's not disabled and sets verbose mode @@ -31,7 +31,7 @@ catch_errors() { # This function handles errors error_handler() { - source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/api.func) + source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) printf "\e[?25h" local exit_code="$?" local line_number="$1" @@ -148,7 +148,7 @@ EOF $STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED msg_ok "Updated Container OS" - source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/tools.func) + source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/tools.func) } # This function modifies the message of the day (motd) and SSH settings @@ -196,7 +196,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From 95030997c5159f019ee6d123e892944e4fcd3b97 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Wed, 13 Aug 2025 22:04:15 +0200 Subject: [PATCH 07/24] cr suggetions --- ct/headers/livebook | 6 - ct/livebook.sh | 10 +- frontend/public/json/livebook.json | 24 +-- install.sh | 298 ----------------------------- install/livebook-install.sh | 32 ++-- 5 files changed, 26 insertions(+), 344 deletions(-) delete mode 100644 ct/headers/livebook delete mode 100755 install.sh diff --git a/ct/headers/livebook b/ct/headers/livebook deleted file mode 100644 index 7b50abfd..00000000 --- a/ct/headers/livebook +++ /dev/null @@ -1,6 +0,0 @@ - __ _ __ __ - / / (_) _____ / /_ ____ ____ / /__ - / / / / | / / _ \/ __ \/ __ \/ __ \/ //_/ - / /___/ /| |/ / __/ /_/ / /_/ / /_/ / ,< -/_____/_/ |___/\___/_.___/\____/\____/_/|_| - diff --git a/ct/livebook.sh b/ct/livebook.sh index 81bc3e2a..3ed7697d 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: dkuku # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE @@ -25,13 +25,11 @@ function update_script() { check_container_storage check_container_resources - # Check if Livebook is installed - if [[ ! -f /opt/${APP}_version.txt ]]; then + if [[ ! -f /opt/.mix/escripts/livebook ]]; then msg_error "No ${APP} Installation Found!" exit 1 fi - # Get the latest version from GitHub msg_info "Checking for updates..." RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') @@ -40,7 +38,6 @@ function update_script() { exit 1 fi - # Check if version file exists and compare versions if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then msg_info "Updating ${APP} LXC" $STD apt-get update @@ -51,9 +48,8 @@ function update_script() { source /opt/.env cd /opt || exit 1 rm /opt/.mix/escripts/livebook - mix escript.install hex livebook --force >/dev/null 2>&1 + mix escript.install hex livebook --force - # Save the new version echo "$RELEASE" | $STD tee /opt/${APP}_version.txt >/dev/null msg_ok "Successfully updated to ${RELEASE}" diff --git a/frontend/public/json/livebook.json b/frontend/public/json/livebook.json index f5599d2b..db4159ca 100644 --- a/frontend/public/json/livebook.json +++ b/frontend/public/json/livebook.json @@ -2,28 +2,28 @@ "name": "Livebook", "slug": "livebook", "categories": [ - 8 + 20 ], - "date_created": "2025-08-10", + "date_created": "2025-08-12", "type": "ct", "updateable": true, "privileged": false, - "config_path": "/data/.env", "interface_port": 8080, - "documentation": "https://livebook.dev/", - "website": "https://livebook.dev/", + "documentation": null, + "config_path": "/opt/.env", + "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.", + "description": "Elixir Livebook is an interactive, web-based notebook platform for Elixir that combines code, documentation, and visualizations in a single document. Similar to Jupyter notebooks, it allows developers to write and execute Elixir code in real-time, making it ideal for data exploration, prototyping, learning, and collaborative development. Livebook features rich markdown support, built-in charting capabilities, and seamless integration with the Elixir ecosystem.", "install_methods": [ { "type": "default", "script": "ct/livebook.sh", "resources": { - "cpu": 2, + "cpu": 1, "ram": 1024, "hdd": 4, "os": "Ubuntu", - "version": "24" + "version": "24.04" } } ], @@ -31,11 +31,5 @@ "username": null, "password": null }, - "notes": [ - "Default port is 8080", - "Working directory is /data", - "Home directory is /opt", - "Elixir runtime with Mix.install/2 support", - "Service runs as root user" - ] + "notes": [] } diff --git a/install.sh b/install.sh deleted file mode 100755 index f1647a15..00000000 --- a/install.sh +++ /dev/null @@ -1,298 +0,0 @@ -#!/bin/sh -# See latest version at: -# https://github.com/elixir-lang/elixir-lang.github.com/blob/main/install.sh - -set -eu - -otp_version= -elixir_version= -force=false - -usage() { - cat<&2 - exit 1 - ;; - esac - done - - if [ -z "${elixir_version}" ]; then - usage - echo "error: missing elixir@VERSION argument" - exit 1 - fi - - if [ -z "${otp_version}" ]; then - usage - echo "error: missing otp@VERSION argument" - exit 1 - fi - - root_dir="$HOME/.elixir-install" - tmp_dir="$root_dir/tmp" - mkdir -p "$tmp_dir" - - if [ "${otp_version}" = latest ]; then - url=$(curl -fsS --head https://github.com/erlef/otp_builds/releases/latest | grep -i '^location:' | awk '{print $2}' | tr -d '\r\n') - tag=$(basename "$url") - otp_version="${tag#OTP-}" - fi - - if [ "${elixir_version}" = latest ]; then - url=$(curl -fsS --head https://github.com/elixir-lang/elixir/releases/latest | grep -i '^location:' | awk '{print $2}' | tr -d '\r\n') - tag=$(basename "$url") - elixir_version="${tag#v}" - fi - - case "${otp_version}" in - master|maint*) - branch_version=$(curl -fsS https://raw.githubusercontent.com/erlang/otp/refs/heads/${otp_version}/OTP_VERSION | tr -d '\n') - elixir_otp_release="${branch_version%%.*}" - ;; - *) - elixir_otp_release="${otp_version%%.*}" - ;; - esac - - case "$elixir_version" in - 1.14.*) - [ "${elixir_otp_release}" -ge 25 ] && elixir_otp_release=25 - ;; - 1.15.*|1.16.*) - [ "${elixir_otp_release}" -ge 26 ] && elixir_otp_release=26 - ;; - 1.17.*|1.18.*) - [ "${elixir_otp_release}" -ge 27 ] && elixir_otp_release=27 - ;; - 1.19.*) - [ "${elixir_otp_release}" -ge 28 ] && elixir_otp_release=28 - ;; - *) - [ "${elixir_otp_release}" -ge 28 ] && elixir_otp_release=28 - ;; - esac - - otp_dir="$root_dir/installs/otp/$otp_version" - elixir_dir="${root_dir}/installs/elixir/${elixir_version}-otp-${elixir_otp_release}" - - if unzip_available; then - install_otp & - pid_otp=$! - - install_elixir & - pid_elixir=$! - - wait $pid_otp - wait $pid_elixir - else - # if unzip is missing (e.g. official docker ubuntu image), install otp and elixir - # serially because we unzip elixir using OTP zip:extract/2. - install_otp - install_elixir - fi - - printf "checking OTP... " - export PATH="$otp_dir/bin:$PATH" - erl -noshell -eval 'io:put_chars(erlang:system_info(otp_release) ++ " ok\n"), halt().' - - printf "checking Elixir... " - "$elixir_dir/bin/elixir" -e 'IO.puts(System.version() <> " ok")' - - export PATH="$elixir_dir/bin:$PATH" -cat</dev/null 2>&1 -} - -main "$@" diff --git a/install/livebook-install.sh b/install/livebook-install.sh index 20ae054e..67793003 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -14,36 +14,35 @@ network_check update_os msg_info "Installing Dependencies (matching Livebook Dockerfile)" -$STD apt-get install --no-install-recommends -y \ +$STD apt-get install -y \ build-essential \ ca-certificates \ cmake \ - curl \ git \ libncurses5-dev msg_ok "Installed Dependencies" - -msg_info "Installing Erlang and Elixir" +msg_info "Installing Erlang and Elixir +ELIXIR_VERSION=1.18.4-otp-27 +ERLANG_VERSION=27.3.4 mkdir -p /opt /data export HOME=/opt touch $HOME/.env cd /opt || exit 1 curl -fsSO https://elixir-lang.org/install.sh -sh install.sh elixir@1.18.4 otp@27.3.4 >/dev/null 2>&1 +$STD sh install.sh elixir@$ELXIR_VERSION otp@$ERLANG_VERSION echo 'export HOME=/opt' >> $HOME/.env -echo 'export PATH="/opt/.elixir-install/installs/otp/27.3.4/bin:/opt/.elixir-install/installs/elixir/1.18.4-otp-27/bin:$PATH"' >> $HOME/.env -msg_ok "Installed Erlang 27.3.4 and Elixir 1.18.4" +echo 'export PATH="/opt/.elixir-install/installs/otp/${ERLANG_VERSION}/bin:/opt/.elixir-install/installs/elixir/${ELIXIR_VERSION}/bin:$PATH"' >> $HOME/.env +msg_ok "Installed Erlang and Elixir" msg_info "Installing Livebook" RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') -echo "${RELEASE}" >/opt/Livebook_version.txt source /opt/.env cd /opt || exit 1 -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 +$STD mix local.hex --force +$STD mix local.rebar --force +$STD mix escript.install hex livebook --force echo 'export PATH="$HOME/.mix/escripts:$PATH"' >> ~/.env msg_ok "Installed Livebook" @@ -75,17 +74,14 @@ StandardError=journal WantedBy=multi-user.target EOF -$STD systemctl enable livebook.service -$STD systemctl start livebook.service +systemctl enable -q --now livebook msg_ok "Created Livebook Service" +motd_ssh +customize + msg_info "Cleaning Up" rm -f /opt/install.sh $STD apt-get autoremove -y $STD apt-get autoclean msg_ok "Cleaned Up" - -motd_ssh -customize - -echo -e "\n${CREATING}${GN}Livebook Installation Complete!${CL}\n" From aa25f6d3e3c3aa2fb0ecffbd51289d616a078795 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 07:50:40 +0200 Subject: [PATCH 08/24] test new logic --- ct/livebook.sh | 3 +- install/livebook-install.sh | 61 +++++++++++++++++++++---------------- misc/build.func | 2 +- misc/install.func | 3 +- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index 3ed7697d..ea387437 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) +#source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: dkuku # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE diff --git a/install/livebook-install.sh b/install/livebook-install.sh index 67793003..84db422b 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -22,31 +22,48 @@ $STD apt-get install -y \ libncurses5-dev msg_ok "Installed Dependencies" -msg_info "Installing Erlang and Elixir -ELIXIR_VERSION=1.18.4-otp-27 -ERLANG_VERSION=27.3.4 +msg_info "Installing Erlang and Elixir" + mkdir -p /opt /data export HOME=/opt -touch $HOME/.env cd /opt || exit 1 -curl -fsSO https://elixir-lang.org/install.sh -$STD sh install.sh elixir@$ELXIR_VERSION otp@$ERLANG_VERSION -echo 'export HOME=/opt' >> $HOME/.env -echo 'export PATH="/opt/.elixir-install/installs/otp/${ERLANG_VERSION}/bin:/opt/.elixir-install/installs/elixir/${ELIXIR_VERSION}/bin:$PATH"' >> $HOME/.env -msg_ok "Installed Erlang and Elixir" -msg_info "Installing Livebook" +curl -fsSO https://elixir-lang.org/install.sh +$STD sh install.sh elixir@latest otp@latest RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') -source /opt/.env -cd /opt || exit 1 $STD mix local.hex --force $STD mix local.rebar --force $STD mix escript.install hex livebook --force -echo 'export PATH="$HOME/.mix/escripts:$PATH"' >> ~/.env -msg_ok "Installed Livebook" -msg_info "Creating Livebook Service" +# Get the actual installed versions from directory names +ERLANG_VERSION=$(ls /opt/.elixir-install/installs/otp/ | head -n1) +ELIXIR_VERSION=$(ls /opt/.elixir-install/installs/elixir/ | head -n1) + +# TODO remove +echo "Found Erlang version: $ERLANG_VERSION" +echo "Found Elixir version: $ELIXIR_VERSION" + +# Create .env file with all environment variables +cat < /opt/.env +export HOME=/opt +export LIVEBOOK_VERSION=$RELEASE +export ERLANG_VERSION=$ERLANG_VERSION +export ELIXIR_VERSION=$ELIXIR_VERSION +export LIVEBOOK_PORT=8080 +export LIVEBOOK_IP="::" +export LIVEBOOK_HOME=/data +export LIVEBOOK_TOKEN_ENABLED=false +export ESCRIPTS_BIN=/opt/.mix/escripts +export ERLANG_BIN="/opt/.elixir-install/installs/otp/\${ERLANG_VERSION}/bin" +export ELIXIR_BIN="/opt/.elixir-install/installs/elixir/\${ELIXIR_VERSION}/bin" +export PATH="\$ESCRIPTS_BIN:\$ERLANG_BIN:\$ELIXIR_BIN:\$PATH" +EOF + +msg_ok "Installed Erlang $ERLANG_VERSION and Elixir $ELIXIR_VERSION" + +msg_info "Installing Livebook" + cat </etc/systemd/system/livebook.service [Unit] Description=Livebook @@ -57,25 +74,17 @@ Type=exec User=root Group=root WorkingDirectory=/data -Environment=MIX_ENV=prod -Environment=HOME=/opt -Environment=PATH=/opt/.mix/escripts:/opt/.elixir-install/installs/otp/27.3.4/bin:/opt/.elixir-install/installs/elixir/1.18.4-otp-27/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -Environment=LIVEBOOK_PORT=8080 -Environment=LIVEBOOK_IP="::" -Environment=LIVEBOOK_HOME=/data -Environment=LIVEBOOK_TOKEN_ENABLED=false -ExecStart=/bin/bash -c 'cd /opt && livebook server' +EnvironmentFile=-/opt/.env +ExecStart=/bin/bash -c 'source /opt/.env && cd /opt && livebook server' Restart=always RestartSec=5 -StandardOutput=journal -StandardError=journal [Install] WantedBy=multi-user.target EOF systemctl enable -q --now livebook -msg_ok "Created Livebook Service" +msg_ok "Installed Livebook" motd_ssh customize diff --git a/misc/build.func b/misc/build.func index c40a57bd..49b20b7f 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1438,7 +1438,7 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index e3751c29..9b6bd60e 100644 --- a/misc/install.func +++ b/misc/install.func @@ -196,7 +196,8 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + # echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From 5871cdbe5b6fdf3132fd53146c0d658458408df8 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 08:29:29 +0200 Subject: [PATCH 09/24] export path --- install/livebook-install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install/livebook-install.sh b/install/livebook-install.sh index 84db422b..1ee98818 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -32,10 +32,6 @@ curl -fsSO https://elixir-lang.org/install.sh $STD sh install.sh elixir@latest otp@latest RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') -$STD mix local.hex --force -$STD mix local.rebar --force -$STD mix escript.install hex livebook --force - # Get the actual installed versions from directory names ERLANG_VERSION=$(ls /opt/.elixir-install/installs/otp/ | head -n1) ELIXIR_VERSION=$(ls /opt/.elixir-install/installs/elixir/ | head -n1) @@ -43,6 +39,11 @@ ELIXIR_VERSION=$(ls /opt/.elixir-install/installs/elixir/ | head -n1) # TODO remove echo "Found Erlang version: $ERLANG_VERSION" echo "Found Elixir version: $ELIXIR_VERSION" +export PATH="\$ERLANG_BIN:\$ELIXIR_BIN:\$PATH" + +$STD mix local.hex --force +$STD mix local.rebar --force +$STD mix escript.install hex livebook --force # Create .env file with all environment variables cat < /opt/.env @@ -63,7 +64,6 @@ EOF msg_ok "Installed Erlang $ERLANG_VERSION and Elixir $ELIXIR_VERSION" msg_info "Installing Livebook" - cat </etc/systemd/system/livebook.service [Unit] Description=Livebook From af23f69437ba63595a2aed1ba21216087544e37d Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 08:38:11 +0200 Subject: [PATCH 10/24] update path again --- install/livebook-install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install/livebook-install.sh b/install/livebook-install.sh index 1ee98818..d1521c1b 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -19,7 +19,8 @@ $STD apt-get install -y \ ca-certificates \ cmake \ git \ - libncurses5-dev + libncurses5-dev \ + curl msg_ok "Installed Dependencies" msg_info "Installing Erlang and Elixir" @@ -39,7 +40,9 @@ ELIXIR_VERSION=$(ls /opt/.elixir-install/installs/elixir/ | head -n1) # TODO remove echo "Found Erlang version: $ERLANG_VERSION" echo "Found Elixir version: $ELIXIR_VERSION" -export PATH="\$ERLANG_BIN:\$ELIXIR_BIN:\$PATH" +export ERLANG_BIN="/opt/.elixir-install/installs/otp/\${ERLANG_VERSION}/bin" +export ELIXIR_BIN="/opt/.elixir-install/installs/elixir/\${ELIXIR_VERSION}/bin" +export PATH=$ERLANG_BIN:$ELIXIR_BIN:$PATH $STD mix local.hex --force $STD mix local.rebar --force From 02c3ae2a1bf947610cf2c5806ab226ddf508dd79 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 08:51:39 +0200 Subject: [PATCH 11/24] variables --- install/livebook-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/livebook-install.sh b/install/livebook-install.sh index d1521c1b..7db27a3f 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -40,9 +40,9 @@ ELIXIR_VERSION=$(ls /opt/.elixir-install/installs/elixir/ | head -n1) # TODO remove echo "Found Erlang version: $ERLANG_VERSION" echo "Found Elixir version: $ELIXIR_VERSION" -export ERLANG_BIN="/opt/.elixir-install/installs/otp/\${ERLANG_VERSION}/bin" -export ELIXIR_BIN="/opt/.elixir-install/installs/elixir/\${ELIXIR_VERSION}/bin" -export PATH=$ERLANG_BIN:$ELIXIR_BIN:$PATH +export ERLANG_BIN="/opt/.elixir-install/installs/otp/$ERLANG_VERSION/bin" +export ELIXIR_BIN="/opt/.elixir-install/installs/elixir/$ELIXIR_VERSION/bin" +export PATH="$ERLANG_BIN:$ELIXIR_BIN:$PATH" $STD mix local.hex --force $STD mix local.rebar --force From d1c5ac135f347b0b78b6947dff616714c13d5525 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 09:30:10 +0200 Subject: [PATCH 12/24] restore path --- ct/livebook.sh | 3 +-- misc/build.func | 2 +- misc/install.func | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index ea387437..3ed7697d 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -#source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) -source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: dkuku # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE diff --git a/misc/build.func b/misc/build.func index 49b20b7f..c40a57bd 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1438,7 +1438,7 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index 9b6bd60e..e3751c29 100644 --- a/misc/install.func +++ b/misc/install.func @@ -196,8 +196,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - # echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update - echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From dd3fccdc76cc6db525c006bdf7f0a8aba30f5b09 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 10:52:58 +0200 Subject: [PATCH 13/24] run as livebook user --- ct/livebook.sh | 11 +++-------- install/livebook-install.sh | 26 ++++++++++++++++++-------- misc/build.func | 3 ++- misc/install.func | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index 3ed7697d..fa936b00 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) +# source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/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/livebook-dev/livebook -echo -e "Loading..." APP="Livebook" var_tags="${var_tags:-development}" var_disk="${var_disk:-4}" @@ -33,11 +33,6 @@ function update_script() { msg_info "Checking for updates..." RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') - if [[ -z "$RELEASE" ]]; then - msg_error "Failed to fetch latest version information" - exit 1 - fi - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then msg_info "Updating ${APP} LXC" $STD apt-get update @@ -47,10 +42,10 @@ function update_script() { msg_info "Updating ${APP} to ${RELEASE}" source /opt/.env cd /opt || exit 1 - rm /opt/.mix/escripts/livebook mix escript.install hex livebook --force echo "$RELEASE" | $STD tee /opt/${APP}_version.txt >/dev/null + chown -R livebook:livebook /opt /data msg_ok "Successfully updated to ${RELEASE}" else diff --git a/install/livebook-install.sh b/install/livebook-install.sh index 7db27a3f..0ff20ee6 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -23,6 +23,10 @@ $STD apt-get install -y \ curl msg_ok "Installed Dependencies" +msg_info "Creating livebook user" +adduser --system --group --home /opt --shell /bin/bash livebook +msg_ok "Created livebook user" + msg_info "Installing Erlang and Elixir" mkdir -p /opt /data @@ -33,13 +37,9 @@ curl -fsSO https://elixir-lang.org/install.sh $STD sh install.sh elixir@latest otp@latest RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') -# Get the actual installed versions from directory names ERLANG_VERSION=$(ls /opt/.elixir-install/installs/otp/ | head -n1) ELIXIR_VERSION=$(ls /opt/.elixir-install/installs/elixir/ | head -n1) -# TODO remove -echo "Found Erlang version: $ERLANG_VERSION" -echo "Found Elixir version: $ELIXIR_VERSION" export ERLANG_BIN="/opt/.elixir-install/installs/otp/$ERLANG_VERSION/bin" export ELIXIR_BIN="/opt/.elixir-install/installs/elixir/$ELIXIR_VERSION/bin" export PATH="$ERLANG_BIN:$ELIXIR_BIN:$PATH" @@ -48,7 +48,13 @@ $STD mix local.hex --force $STD mix local.rebar --force $STD mix escript.install hex livebook --force -# Create .env file with all environment variables +LIVEBOOK_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c16) + +cat < /opt/livebook.creds +Livebook-Credentials +Livebook Password: $LIVEBOOK_PASSWORD +EOF + cat < /opt/.env export HOME=/opt export LIVEBOOK_VERSION=$RELEASE @@ -57,7 +63,7 @@ export ELIXIR_VERSION=$ELIXIR_VERSION export LIVEBOOK_PORT=8080 export LIVEBOOK_IP="::" export LIVEBOOK_HOME=/data -export LIVEBOOK_TOKEN_ENABLED=false +export LIVEBOOK_PASSWORD="$LIVEBOOK_PASSWORD" export ESCRIPTS_BIN=/opt/.mix/escripts export ERLANG_BIN="/opt/.elixir-install/installs/otp/\${ERLANG_VERSION}/bin" export ELIXIR_BIN="/opt/.elixir-install/installs/elixir/\${ELIXIR_VERSION}/bin" @@ -74,8 +80,8 @@ After=network.target [Service] Type=exec -User=root -Group=root +User=livebook +Group=livebook WorkingDirectory=/data EnvironmentFile=-/opt/.env ExecStart=/bin/bash -c 'source /opt/.env && cd /opt && livebook server' @@ -86,6 +92,10 @@ RestartSec=5 WantedBy=multi-user.target EOF +msg_info "Setting ownership and permissions" +chown -R livebook:livebook /opt /data +msg_ok "Set ownership and permissions" + systemctl enable -q --now livebook msg_ok "Installed Livebook" diff --git a/misc/build.func b/misc/build.func index c40a57bd..f72fb518 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1438,7 +1438,8 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" + } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index e3751c29..a75297aa 100644 --- a/misc/install.func +++ b/misc/install.func @@ -196,7 +196,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://github.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From dec63bf34a4eb582ffaaa90d31179fe6598332a8 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 11:01:25 +0200 Subject: [PATCH 14/24] reset private urls --- ct/livebook.sh | 3 +-- misc/build.func | 3 +-- misc/install.func | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index fa936b00..7f9e848e 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -# source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) -source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: dkuku # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE diff --git a/misc/build.func b/misc/build.func index f72fb518..c40a57bd 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1438,8 +1438,7 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" - + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index a75297aa..e3751c29 100644 --- a/misc/install.func +++ b/misc/install.func @@ -196,7 +196,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://github.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From 953d9f0527515eb40f6ee482383fc98eed9d16a3 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 11:07:28 +0200 Subject: [PATCH 15/24] add info about the password --- frontend/public/json/livebook.json | 7 ++++++- install/livebook-install.sh | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/public/json/livebook.json b/frontend/public/json/livebook.json index db4159ca..8b0a3589 100644 --- a/frontend/public/json/livebook.json +++ b/frontend/public/json/livebook.json @@ -31,5 +31,10 @@ "username": null, "password": null }, - "notes": [] + "notes": [ + { + "text": "Show Livebook password: `cat /opt/livebook.creds`", + "type": "info" + } + ] } diff --git a/install/livebook-install.sh b/install/livebook-install.sh index 0ff20ee6..cc225a08 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -99,6 +99,9 @@ msg_ok "Set ownership and permissions" systemctl enable -q --now livebook msg_ok "Installed Livebook" +msg_info "Livebook password stored in /opt/livebook.creds" +msg_ok "Installation completed successfully" + motd_ssh customize From a89a5351e36fc02107f1f69829d014cf128b5d13 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 11:21:56 +0200 Subject: [PATCH 16/24] remove curl from deps --- install/livebook-install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install/livebook-install.sh b/install/livebook-install.sh index cc225a08..c87e2ca4 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -19,8 +19,7 @@ $STD apt-get install -y \ ca-certificates \ cmake \ git \ - libncurses5-dev \ - curl + libncurses5-dev msg_ok "Installed Dependencies" msg_info "Creating livebook user" From 319a779d4913157b551d000f3e89416cebc2a9b9 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 20:19:55 +0200 Subject: [PATCH 17/24] cr suggetions --- ct/livebook.sh | 15 ++++++++------- install/livebook-install.sh | 36 ++++++++++++++++++------------------ misc/build.func | 2 +- misc/install.func | 2 +- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index 7f9e848e..733cd0e3 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/build.func) +#source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: dkuku # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE @@ -24,7 +25,7 @@ function update_script() { check_container_storage check_container_resources - if [[ ! -f /opt/.mix/escripts/livebook ]]; then + if [[ ! -f /opt/livebook/.mix/escripts/livebook ]]; then msg_error "No ${APP} Installation Found!" exit 1 fi @@ -32,19 +33,19 @@ function update_script() { msg_info "Checking for updates..." RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null)" ]]; then + if [[ "${RELEASE}" != "$(cat /opt/.livebook 2>/dev/null)" ]]; then msg_info "Updating ${APP} LXC" $STD apt-get update $STD apt-get -y upgrade msg_ok "Updated ${APP} LXC" msg_info "Updating ${APP} to ${RELEASE}" - source /opt/.env - cd /opt || exit 1 + source /opt/livebook/.env + cd /opt/livebook || exit 1 mix escript.install hex livebook --force - echo "$RELEASE" | $STD tee /opt/${APP}_version.txt >/dev/null - chown -R livebook:livebook /opt /data + echo "$RELEASE" | $STD tee /opt/.livebook + chown -R livebook:livebook /opt/livebook /data msg_ok "Successfully updated to ${RELEASE}" else diff --git a/install/livebook-install.sh b/install/livebook-install.sh index c87e2ca4..aa2e1b03 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -13,7 +13,7 @@ setting_up_container network_check update_os -msg_info "Installing Dependencies (matching Livebook Dockerfile)" +msg_info "Installing Dependencies" $STD apt-get install -y \ build-essential \ ca-certificates \ @@ -23,24 +23,24 @@ $STD apt-get install -y \ msg_ok "Installed Dependencies" msg_info "Creating livebook user" -adduser --system --group --home /opt --shell /bin/bash livebook +adduser --system --group --home /opt/livebook --shell /bin/bash livebook msg_ok "Created livebook user" msg_info "Installing Erlang and Elixir" -mkdir -p /opt /data -export HOME=/opt -cd /opt || exit 1 +mkdir -p /opt/livebook /data +export HOME=/opt/livebook +cd /opt/livebook || exit 1 curl -fsSO https://elixir-lang.org/install.sh $STD sh install.sh elixir@latest otp@latest RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') -ERLANG_VERSION=$(ls /opt/.elixir-install/installs/otp/ | head -n1) -ELIXIR_VERSION=$(ls /opt/.elixir-install/installs/elixir/ | head -n1) +ERLANG_VERSION=$(ls /opt/livebook/.elixir-install/installs/otp/ | head -n1) +ELIXIR_VERSION=$(ls /opt/livebook/.elixir-install/installs/elixir/ | head -n1) -export ERLANG_BIN="/opt/.elixir-install/installs/otp/$ERLANG_VERSION/bin" -export ELIXIR_BIN="/opt/.elixir-install/installs/elixir/$ELIXIR_VERSION/bin" +export ERLANG_BIN="/opt/livebook/.elixir-install/installs/otp/$ERLANG_VERSION/bin" +export ELIXIR_BIN="/opt/livebook/.elixir-install/installs/elixir/$ELIXIR_VERSION/bin" export PATH="$ERLANG_BIN:$ELIXIR_BIN:$PATH" $STD mix local.hex --force @@ -49,13 +49,13 @@ $STD mix escript.install hex livebook --force LIVEBOOK_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c16) -cat < /opt/livebook.creds +cat < /opt/livebook/livebook.creds Livebook-Credentials Livebook Password: $LIVEBOOK_PASSWORD EOF -cat < /opt/.env -export HOME=/opt +cat < /opt/livebook/.env +export HOME=/opt/livebook export LIVEBOOK_VERSION=$RELEASE export ERLANG_VERSION=$ERLANG_VERSION export ELIXIR_VERSION=$ELIXIR_VERSION @@ -63,9 +63,9 @@ export LIVEBOOK_PORT=8080 export LIVEBOOK_IP="::" export LIVEBOOK_HOME=/data export LIVEBOOK_PASSWORD="$LIVEBOOK_PASSWORD" -export ESCRIPTS_BIN=/opt/.mix/escripts -export ERLANG_BIN="/opt/.elixir-install/installs/otp/\${ERLANG_VERSION}/bin" -export ELIXIR_BIN="/opt/.elixir-install/installs/elixir/\${ELIXIR_VERSION}/bin" +export ESCRIPTS_BIN=/opt/livebook/.mix/escripts +export ERLANG_BIN="/opt/livebook/.elixir-install/installs/otp/\${ERLANG_VERSION}/bin" +export ELIXIR_BIN="/opt/livebook/.elixir-install/installs/elixir/\${ELIXIR_VERSION}/bin" export PATH="\$ESCRIPTS_BIN:\$ERLANG_BIN:\$ELIXIR_BIN:\$PATH" EOF @@ -82,8 +82,8 @@ Type=exec User=livebook Group=livebook WorkingDirectory=/data -EnvironmentFile=-/opt/.env -ExecStart=/bin/bash -c 'source /opt/.env && cd /opt && livebook server' +EnvironmentFile=-/opt/livebook/.env +ExecStart=/bin/bash -c 'source /opt/livebook/.env && cd /opt/livebook && livebook server' Restart=always RestartSec=5 @@ -92,7 +92,7 @@ WantedBy=multi-user.target EOF msg_info "Setting ownership and permissions" -chown -R livebook:livebook /opt /data +chown -R livebook:livebook /opt/livebook /data msg_ok "Set ownership and permissions" systemctl enable -q --now livebook diff --git a/misc/build.func b/misc/build.func index c40a57bd..49b20b7f 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1438,7 +1438,7 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index e3751c29..d1facfa4 100644 --- a/misc/install.func +++ b/misc/install.func @@ -196,7 +196,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From e24f867d9d70f4aea7b42caeb4d1a238f4e242b2 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 17 Aug 2025 20:57:56 +0200 Subject: [PATCH 18/24] reset private urls --- ct/livebook.sh | 3 +-- misc/build.func | 2 +- misc/install.func | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index 733cd0e3..d934ec25 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/build.func) -#source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: dkuku # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE diff --git a/misc/build.func b/misc/build.func index 49b20b7f..c40a57bd 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1438,7 +1438,7 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index d1facfa4..e3751c29 100644 --- a/misc/install.func +++ b/misc/install.func @@ -196,7 +196,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From 613569c035cb79978ad583efb4e0c33db482013c Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 31 Aug 2025 18:38:52 +0200 Subject: [PATCH 19/24] temp-change github path --- ct/livebook.sh | 3 ++- misc/build.func | 2 +- misc/install.func | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index d934ec25..42e8937e 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) +#source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: dkuku # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE diff --git a/misc/build.func b/misc/build.func index c40a57bd..49b20b7f 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1438,7 +1438,7 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index e3751c29..da0337a5 100644 --- a/misc/install.func +++ b/misc/install.func @@ -196,7 +196,8 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + #echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From 929c6e8fb311ae15f988a7d344bd8b59245fdb23 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 31 Aug 2025 19:01:21 +0200 Subject: [PATCH 20/24] update messages --- install/livebook-install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install/livebook-install.sh b/install/livebook-install.sh index aa2e1b03..06cb914f 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -23,7 +23,7 @@ $STD apt-get install -y \ msg_ok "Installed Dependencies" msg_info "Creating livebook user" -adduser --system --group --home /opt/livebook --shell /bin/bash livebook +$STD adduser --system --group --home /opt/livebook --shell /bin/bash livebook msg_ok "Created livebook user" msg_info "Installing Erlang and Elixir" @@ -47,12 +47,14 @@ $STD mix local.hex --force $STD mix local.rebar --force $STD mix escript.install hex livebook --force +msg_info "Setting Livebook password" LIVEBOOK_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c16) cat < /opt/livebook/livebook.creds Livebook-Credentials Livebook Password: $LIVEBOOK_PASSWORD EOF +msg_ok "Livebook password stored in /opt/livebook/livebook.creds" cat < /opt/livebook/.env export HOME=/opt/livebook @@ -98,7 +100,6 @@ msg_ok "Set ownership and permissions" systemctl enable -q --now livebook msg_ok "Installed Livebook" -msg_info "Livebook password stored in /opt/livebook.creds" msg_ok "Installation completed successfully" motd_ssh From 91bf3257518f0a1d6a49f563328fd1dd913f6456 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 31 Aug 2025 19:08:10 +0200 Subject: [PATCH 21/24] mute logs --- ct/livebook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index 42e8937e..51323f89 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -42,7 +42,7 @@ function update_script() { msg_info "Updating ${APP} to ${RELEASE}" source /opt/livebook/.env cd /opt/livebook || exit 1 - mix escript.install hex livebook --force + $STD mix escript.install hex livebook --force echo "$RELEASE" | $STD tee /opt/.livebook chown -R livebook:livebook /opt/livebook /data From fc871466faea3161d013401db3acbe517822d4ce Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 31 Aug 2025 19:28:37 +0200 Subject: [PATCH 22/24] restore github links --- ct/livebook.sh | 3 +-- misc/build.func | 2 +- misc/install.func | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index 51323f89..b0d0e9fe 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -#source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) -source <(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: dkuku # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE diff --git a/misc/build.func b/misc/build.func index 49b20b7f..c40a57bd 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1438,7 +1438,7 @@ EOF' fi msg_ok "Customized LXC Container" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/install/${var_install}.sh)" + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/${var_install}.sh)" } destroy_lxc() { diff --git a/misc/install.func b/misc/install.func index da0337a5..e3751c29 100644 --- a/misc/install.func +++ b/misc/install.func @@ -196,8 +196,7 @@ EOF systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') msg_ok "Customized Container" fi - #echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update - echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/dkuku/ProxmoxVED/refs/heads/livebook/ct/${app}.sh)\"" >/usr/bin/update + echo "bash -c \"\$(curl -fsSL https://github.com/community-scripts/ProxmoxVED/raw/main/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then mkdir -p /root/.ssh From ec831b8c02961920c53105e20edf670a9eab4369 Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 31 Aug 2025 19:42:42 +0200 Subject: [PATCH 23/24] move version file to home folder --- ct/livebook.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index b0d0e9fe..f6cb59d6 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -32,7 +32,7 @@ function update_script() { msg_info "Checking for updates..." RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') - if [[ "${RELEASE}" != "$(cat /opt/.livebook 2>/dev/null)" ]]; then + if [[ "${RELEASE}" != "$(cat /opt/livebook/.livebook 2>/dev/null)" ]]; then msg_info "Updating ${APP} LXC" $STD apt-get update $STD apt-get -y upgrade @@ -43,7 +43,7 @@ function update_script() { cd /opt/livebook || exit 1 $STD mix escript.install hex livebook --force - echo "$RELEASE" | $STD tee /opt/.livebook + echo "$RELEASE" | $STD tee /opt/livebook/.livebook chown -R livebook:livebook /opt/livebook /data msg_ok "Successfully updated to ${RELEASE}" From 3f5166ea106f2bb9550aa98d8981372322a8a90c Mon Sep 17 00:00:00 2001 From: Daniel Kukula Date: Sun, 7 Sep 2025 14:29:10 +0200 Subject: [PATCH 24/24] use new gh_release check, update logging --- ct/livebook.sh | 26 +++++++++++--------------- install/livebook-install.sh | 23 ++++++++--------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/ct/livebook.sh b/ct/livebook.sh index f6cb59d6..438c14f4 100755 --- a/ct/livebook.sh +++ b/ct/livebook.sh @@ -26,31 +26,28 @@ function update_script() { if [[ ! -f /opt/livebook/.mix/escripts/livebook ]]; then msg_error "No ${APP} Installation Found!" - exit 1 + exit fi - msg_info "Checking for updates..." - RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') + if check_for_gh_release "livebook" "livebook-dev/livebook"; then + msg_info "Stopping ${APP}" + systemctl stop livebook + msg_info "Service stopped" - if [[ "${RELEASE}" != "$(cat /opt/livebook/.livebook 2>/dev/null)" ]]; then - msg_info "Updating ${APP} LXC" + msg_info "Updating container" $STD apt-get update $STD apt-get -y upgrade - msg_ok "Updated ${APP} LXC" + msg_ok "Updated container" - msg_info "Updating ${APP} to ${RELEASE}" + msg_info "Updating ${APP}" source /opt/livebook/.env - cd /opt/livebook || exit 1 + cd /opt/livebook $STD mix escript.install hex livebook --force - echo "$RELEASE" | $STD tee /opt/livebook/.livebook chown -R livebook:livebook /opt/livebook /data - - msg_ok "Successfully updated to ${RELEASE}" - else - msg_ok "No update required. ${APP} is already at ${RELEASE}." + systemctl start livebook + msg_ok "Updated ${APP}" fi - exit } @@ -58,7 +55,6 @@ 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}" diff --git a/install/livebook-install.sh b/install/livebook-install.sh index 06cb914f..1818616e 100644 --- a/install/livebook-install.sh +++ b/install/livebook-install.sh @@ -30,14 +30,14 @@ msg_info "Installing Erlang and Elixir" mkdir -p /opt/livebook /data export HOME=/opt/livebook -cd /opt/livebook || exit 1 +cd /opt/livebook curl -fsSO https://elixir-lang.org/install.sh $STD sh install.sh elixir@latest otp@latest -RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') ERLANG_VERSION=$(ls /opt/livebook/.elixir-install/installs/otp/ | head -n1) ELIXIR_VERSION=$(ls /opt/livebook/.elixir-install/installs/elixir/ | head -n1) +LIVEBOOK_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c16) export ERLANG_BIN="/opt/livebook/.elixir-install/installs/otp/$ERLANG_VERSION/bin" export ELIXIR_BIN="/opt/livebook/.elixir-install/installs/elixir/$ELIXIR_VERSION/bin" @@ -47,18 +47,8 @@ $STD mix local.hex --force $STD mix local.rebar --force $STD mix escript.install hex livebook --force -msg_info "Setting Livebook password" -LIVEBOOK_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c16) - -cat < /opt/livebook/livebook.creds -Livebook-Credentials -Livebook Password: $LIVEBOOK_PASSWORD -EOF -msg_ok "Livebook password stored in /opt/livebook/livebook.creds" - cat < /opt/livebook/.env export HOME=/opt/livebook -export LIVEBOOK_VERSION=$RELEASE export ERLANG_VERSION=$ERLANG_VERSION export ELIXIR_VERSION=$ELIXIR_VERSION export LIVEBOOK_PORT=8080 @@ -93,14 +83,17 @@ RestartSec=5 WantedBy=multi-user.target EOF -msg_info "Setting ownership and permissions" chown -R livebook:livebook /opt/livebook /data -msg_ok "Set ownership and permissions" systemctl enable -q --now livebook msg_ok "Installed Livebook" -msg_ok "Installation completed successfully" +msg_info "Saving Livebook credentials" +cat < /opt/livebook/livebook.creds +Livebook-Credentials +Livebook Password: $LIVEBOOK_PASSWORD +EOF +msg_ok "Livebook password stored in /opt/livebook/livebook.creds" motd_ssh customize