cr suggetions
This commit is contained in:
parent
9fb30f587f
commit
95030997c5
@ -1,6 +0,0 @@
|
||||
__ _ __ __
|
||||
/ / (_) _____ / /_ ____ ____ / /__
|
||||
/ / / / | / / _ \/ __ \/ __ \/ __ \/ //_/
|
||||
/ /___/ /| |/ / __/ /_/ / /_/ / /_/ / ,<
|
||||
/_____/_/ |___/\___/_.___/\____/\____/_/|_|
|
||||
|
@ -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}"
|
||||
|
@ -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": []
|
||||
}
|
||||
|
298
install.sh
298
install.sh
@ -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<<EOF
|
||||
Usage: install.sh elixir@ELIXIR_VERSION otp@OTP_VERSION [options]
|
||||
|
||||
ELIXIR_VERSION can be X.Y.Z, latest, or main.
|
||||
OTP_VERSION can be X.Y.Z, latest, master, maint, or maint-RELEASE (e.g. maint-27).
|
||||
|
||||
Options:
|
||||
|
||||
-f, --force Forces installation even if it was previously installed
|
||||
-h, --help Prints this help
|
||||
|
||||
Examples:
|
||||
|
||||
sh install.sh elixir@1.16.3 otp@26.2.5.4
|
||||
sh install.sh elixir@latest otp@latest
|
||||
sh install.sh elixir@main otp@master
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
elixir@*)
|
||||
elixir_version="${arg#elixir@}"
|
||||
;;
|
||||
otp@*)
|
||||
otp_version="${arg#otp@}"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-f|--force)
|
||||
force=true
|
||||
;;
|
||||
*)
|
||||
echo "error: invalid argument $arg" >&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<<EOF
|
||||
|
||||
Run this (or add to your ~/.bashrc or similar file):
|
||||
|
||||
export PATH=\$HOME/.elixir-install/installs/otp/$otp_version/bin:\$PATH
|
||||
export PATH=\$HOME/.elixir-install/installs/elixir/$elixir_version-otp-$elixir_otp_release/bin:\$PATH
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
install_otp() {
|
||||
os=$(uname -sm)
|
||||
case "$os" in
|
||||
"Darwin x86_64") target=x86_64-apple-darwin ;;
|
||||
"Darwin arm64") target=aarch64-apple-darwin ;;
|
||||
"Linux x86_64") target=x86_64-pc-linux ;;
|
||||
"Linux aarch64") target=aarch64-pc-linux ;;
|
||||
MINGW64*) target=x86_64-pc-windows ;;
|
||||
*) echo "error: unsupported system $os." && exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ ! -d "${otp_dir}/bin" ] || [ "$force" = true ]; then
|
||||
rm -rf "${otp_dir}"
|
||||
|
||||
case "$target" in
|
||||
*windows) install_otp_windows ;;
|
||||
*darwin) install_otp_darwin ;;
|
||||
*linux) install_otp_linux ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
install_otp_darwin() {
|
||||
case "${otp_version}" in
|
||||
master|maint*)
|
||||
ref="${otp_version}-latest"
|
||||
;;
|
||||
*)
|
||||
ref="OTP-${otp_version}"
|
||||
;;
|
||||
esac
|
||||
|
||||
otp_tgz="otp-${target}.tar.gz"
|
||||
url="https://github.com/erlef/otp_builds/releases/download/$ref/$otp_tgz"
|
||||
|
||||
download "$url" "$tmp_dir/$otp_tgz"
|
||||
|
||||
echo "unpacking $otp_tgz to $otp_dir..."
|
||||
mkdir -p "$otp_dir"
|
||||
tar xzf "$tmp_dir/$otp_tgz" -C "$otp_dir"
|
||||
rm "$tmp_dir/$otp_tgz"
|
||||
}
|
||||
|
||||
install_otp_linux() {
|
||||
case "${otp_version}" in
|
||||
master|maint*)
|
||||
otp_tgz="${otp_version}.tar.gz"
|
||||
;;
|
||||
*)
|
||||
otp_tgz="OTP-${otp_version}.tar.gz"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$target" in
|
||||
x86_64*) arch=amd64 ;;
|
||||
aarch64*) arch=arm64 ;;
|
||||
esac
|
||||
|
||||
id=$(grep '^ID=' /etc/os-release | cut -d '=' -f 2)
|
||||
if [ "${id}" != ubuntu ]; then
|
||||
echo $id is not supported
|
||||
exit 1
|
||||
fi
|
||||
case $(grep '^VERSION_ID=' /etc/os-release | cut -d '"' -f 2) in
|
||||
20*|21*)
|
||||
lts=20.04
|
||||
;;
|
||||
22*|23*)
|
||||
lts=22.04
|
||||
;;
|
||||
*)
|
||||
lts=24.04
|
||||
;;
|
||||
esac
|
||||
|
||||
url="https://builds.hex.pm/builds/otp/${arch}/ubuntu-${lts}/$otp_tgz"
|
||||
download "$url" "$tmp_dir/$otp_tgz"
|
||||
|
||||
echo "unpacking $otp_tgz to $otp_dir..."
|
||||
mkdir -p "$otp_dir"
|
||||
tar xzf "$tmp_dir/$otp_tgz" --strip-components 1 -C "$otp_dir"
|
||||
(cd "$otp_dir" && ./Install -sasl "$PWD")
|
||||
rm "$tmp_dir/$otp_tgz"
|
||||
}
|
||||
|
||||
install_otp_windows() {
|
||||
otp_zip="otp_win64_$otp_version.zip"
|
||||
url="https://github.com/erlang/otp/releases/download/OTP-$otp_version/$otp_zip"
|
||||
download "$url" "$tmp_dir/$otp_zip"
|
||||
|
||||
echo "unpacking $otp_zip to $otp_dir..."
|
||||
mkdir -p "$otp_dir"
|
||||
unzip -q "$tmp_dir/$otp_zip" -d "$otp_dir"
|
||||
rm "$tmp_dir/$otp_zip"
|
||||
install_vc_redist
|
||||
}
|
||||
|
||||
install_vc_redist() {
|
||||
if [ ! -f /c/windows/system32/vcruntime140.dll ]; then
|
||||
echo "installing VC++ Redistributable..."
|
||||
(cd $otp_dir && ./vc_redist.exe /quiet /norestart)
|
||||
fi
|
||||
}
|
||||
|
||||
install_elixir() {
|
||||
elixir_zip="elixir-otp-$elixir_otp_release.zip"
|
||||
|
||||
if [ ! -d "${elixir_dir}/bin" ] || [ "$force" = true ]; then
|
||||
case "${elixir_version}" in
|
||||
main)
|
||||
ref="${elixir_version}-latest"
|
||||
;;
|
||||
v[0-9]*.[0-9])
|
||||
ref="v${elixir_version}-latest"
|
||||
;;
|
||||
*)
|
||||
ref="v${elixir_version}"
|
||||
;;
|
||||
esac
|
||||
|
||||
url="https://github.com/elixir-lang/elixir/releases/download/$ref/$elixir_zip"
|
||||
download "$url" "$tmp_dir/$elixir_zip"
|
||||
|
||||
echo "unpacking $elixir_zip to $elixir_dir..."
|
||||
rm -rf "${elixir_dir}"
|
||||
mkdir -p "${elixir_dir}"
|
||||
|
||||
if unzip_available; then
|
||||
unzip -q "${tmp_dir}/${elixir_zip}" -d "${elixir_dir}"
|
||||
else
|
||||
"${otp_dir}/bin/erl" -noshell -eval \
|
||||
'[Zip,Dir] = init:get_plain_arguments(), {ok,_} = zip:unzip(Zip, [{cwd, Dir}]), halt().' \
|
||||
-- "${tmp_dir}/${elixir_zip}" "${elixir_dir}"
|
||||
fi
|
||||
|
||||
rm "${tmp_dir}/${elixir_zip}"
|
||||
fi
|
||||
}
|
||||
|
||||
download() {
|
||||
url="$1"
|
||||
output="$2"
|
||||
echo "downloading $url"
|
||||
curl --retry 3 -fsSLo "$output" "$url"
|
||||
}
|
||||
|
||||
unzip_available() {
|
||||
which unzip >/dev/null 2>&1
|
||||
}
|
||||
|
||||
main "$@"
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user