update logic
This commit is contained in:
parent
ddf32895dc
commit
b6db98b8dc
@ -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
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
# Source: https://github.com/livebook-dev/livebook
|
# Source: https://github.com/livebook-dev/livebook
|
||||||
|
|
||||||
|
echo -e "Loading..."
|
||||||
APP="Livebook"
|
APP="Livebook"
|
||||||
var_tags="${var_tags:-development}"
|
var_tags="${var_tags:-development}"
|
||||||
var_disk="${var_disk:-4}"
|
var_disk="${var_disk:-4}"
|
||||||
@ -25,7 +26,7 @@ function update_script() {
|
|||||||
check_container_resources
|
check_container_resources
|
||||||
|
|
||||||
# Check if Livebook is installed
|
# 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!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -40,41 +41,24 @@ function update_script() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if version file exists and compare versions
|
# Check if version file exists and compare versions
|
||||||
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${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} to v${RELEASE}"
|
#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
|
msg_info "Updating ${APP} to ${RELEASE}"
|
||||||
if [[ -d /home/livebook ]]; then
|
source /opt/.env
|
||||||
msg_info "Creating backup of user data..."
|
cd /opt || exit 1
|
||||||
$STD cp -r /home/livebook /home/livebook-backup
|
mix escript.install hex livebook --force >/dev/null 2>&1
|
||||||
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
|
|
||||||
|
|
||||||
# Save the new version
|
# Save the new version
|
||||||
echo "$RELEASE" | $STD tee /opt/${APP}_version.txt >/dev/null
|
echo "$RELEASE" | $STD tee /opt/${APP}_version.txt >/dev/null
|
||||||
|
|
||||||
# Cleanup backup if update was successful
|
# Cleanup backup if update was successful
|
||||||
if [[ -d /home/livebook-backup ]]; then
|
if [[ -d /opt-backup ]]; then
|
||||||
msg_info "Cleaning up backup..."
|
$STD rm -rf /opt-backup
|
||||||
$STD rm -rf /home/livebook-backup
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_ok "Successfully updated to v${RELEASE}"
|
msg_ok "Successfully updated to v${RELEASE}"
|
||||||
@ -92,7 +76,4 @@ description
|
|||||||
msg_ok "Completed Successfully!\n"
|
msg_ok "Completed Successfully!\n"
|
||||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${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}"
|
|
||||||
|
@ -29,14 +29,13 @@
|
|||||||
],
|
],
|
||||||
"default_credentials": {
|
"default_credentials": {
|
||||||
"username": null,
|
"username": null,
|
||||||
"password": "Check /data/token.txt"
|
"password": null
|
||||||
},
|
},
|
||||||
"notes": [
|
"notes": [
|
||||||
"Access token is stored in /data/token.txt",
|
|
||||||
"Default port is 8080",
|
"Default port is 8080",
|
||||||
"Working directory is /data",
|
"Working directory is /data",
|
||||||
"Home directory is /home/livebook",
|
"Home directory is /opt",
|
||||||
"Elixir runtime with Mix.install/2 support",
|
"Elixir runtime with Mix.install/2 support",
|
||||||
"Service runs as livebook user"
|
"Service runs as root user"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
298
install.sh
Executable file
298
install.sh
Executable file
@ -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<<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 "$@"
|
@ -23,82 +23,29 @@ $STD apt-get install --no-install-recommends -y \
|
|||||||
libncurses5-dev
|
libncurses5-dev
|
||||||
msg_ok "Installed Dependencies"
|
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"
|
msg_info "Installing Erlang and Elixir"
|
||||||
# Create a temporary script
|
mkdir -p /opt /data
|
||||||
cat > /tmp/setup_elixir.sh << 'EOF'
|
|
||||||
#!/bin/bash
|
|
||||||
export HOME=/opt
|
export HOME=/opt
|
||||||
cd /opt
|
touch $HOME/.env
|
||||||
|
cd /opt || exit 1
|
||||||
curl -fsSO https://elixir-lang.org/install.sh
|
curl -fsSO https://elixir-lang.org/install.sh
|
||||||
sh install.sh elixir@1.18.4 otp@27.3.4 >/dev/null 2>&1
|
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 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
|
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
|
||||||
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
|
|
||||||
msg_ok "Installed Erlang 27.3.4 and Elixir 1.18.4"
|
msg_ok "Installed Erlang 27.3.4 and Elixir 1.18.4"
|
||||||
|
|
||||||
msg_info "Installing Livebook"
|
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}')
|
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
|
echo "${RELEASE}" >/opt/Livebook_version.txt
|
||||||
|
|
||||||
set -e # Exit on any error
|
|
||||||
source /opt/.env
|
source /opt/.env
|
||||||
cd $HOME
|
cd /opt || exit 1
|
||||||
|
mix local.hex --force >/dev/null 2>&1
|
||||||
# Install hex and rebar for Mix.install/2 and Mix runtime (matching Dockerfile)
|
mix local.rebar --force >/dev/null 2>&1
|
||||||
echo "Installing hex..."
|
mix escript.install hex livebook --force >/dev/null 2>&1
|
||||||
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
|
echo 'export PATH="$HOME/.mix/escripts:$PATH"' >> ~/.env
|
||||||
|
msg_ok "Installed Livebook"
|
||||||
# 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"
|
msg_info "Creating Livebook Service"
|
||||||
cat <<EOF >/etc/systemd/system/livebook.service
|
cat <<EOF >/etc/systemd/system/livebook.service
|
||||||
@ -108,8 +55,8 @@ After=network.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=exec
|
Type=exec
|
||||||
User=livebook
|
User=root
|
||||||
Group=livebook
|
Group=root
|
||||||
WorkingDirectory=/data
|
WorkingDirectory=/data
|
||||||
Environment=MIX_ENV=prod
|
Environment=MIX_ENV=prod
|
||||||
Environment=HOME=/opt
|
Environment=HOME=/opt
|
||||||
@ -129,6 +76,7 @@ WantedBy=multi-user.target
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
$STD systemctl enable livebook.service
|
$STD systemctl enable livebook.service
|
||||||
|
$STD systemctl start livebook.service
|
||||||
msg_ok "Created Livebook Service"
|
msg_ok "Created Livebook Service"
|
||||||
|
|
||||||
msg_info "Cleaning Up"
|
msg_info "Cleaning Up"
|
||||||
@ -137,11 +85,6 @@ $STD apt-get autoremove -y
|
|||||||
$STD apt-get autoclean
|
$STD apt-get autoclean
|
||||||
msg_ok "Cleaned Up"
|
msg_ok "Cleaned Up"
|
||||||
|
|
||||||
msg_info "Starting Livebook Service"
|
|
||||||
$STD systemctl start livebook.service
|
|
||||||
msg_ok "Started Livebook Service"
|
|
||||||
|
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|
||||||
|
@ -16,10 +16,10 @@ variables() {
|
|||||||
CT_TYPE=${var_unprivileged:-$CT_TYPE}
|
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
|
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
|
load_functions
|
||||||
#echo "(build.func) Loaded core.func via curl"
|
#echo "(build.func) Loaded core.func via curl"
|
||||||
elif command -v wget >/dev/null 2>&1; then
|
elif command -v wget >/dev/null 2>&1; then
|
||||||
@ -988,7 +988,7 @@ install_script() {
|
|||||||
header_info
|
header_info
|
||||||
echo -e "${INFO}${HOLD} ${GN}Using Config File on node $PVEHOST_NAME${CL}"
|
echo -e "${INFO}${HOLD} ${GN}Using Config File on node $PVEHOST_NAME${CL}"
|
||||||
METHOD="advanced"
|
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
|
config_file
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
@ -1061,7 +1061,7 @@ check_container_storage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
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
|
if command -v pveversion >/dev/null 2>&1; then
|
||||||
install_script
|
install_script
|
||||||
elif [ ! -z ${PHS_SILENT+x} ] && [[ "${PHS_SILENT}" == "1" ]]; then
|
elif [ ! -z ${PHS_SILENT+x} ] && [[ "${PHS_SILENT}" == "1" ]]; then
|
||||||
@ -1127,9 +1127,9 @@ build_container() {
|
|||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd "$TEMP_DIR" >/dev/null
|
||||||
if [ "$var_os" == "alpine" ]; then
|
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
|
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
|
fi
|
||||||
export DIAGNOSTICS="$DIAGNOSTICS"
|
export DIAGNOSTICS="$DIAGNOSTICS"
|
||||||
export RANDOM_UUID="$RANDOM_UUID"
|
export RANDOM_UUID="$RANDOM_UUID"
|
||||||
@ -1163,7 +1163,7 @@ build_container() {
|
|||||||
-unprivileged $CT_TYPE
|
-unprivileged $CT_TYPE
|
||||||
$PW
|
$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
|
if [ $? -ne 0 ]; then
|
||||||
exit 200
|
exit 200
|
||||||
fi
|
fi
|
||||||
|
@ -10,7 +10,7 @@ if ! command -v curl >/dev/null 2>&1; then
|
|||||||
apt-get update >/dev/null 2>&1
|
apt-get update >/dev/null 2>&1
|
||||||
apt-get install -y curl >/dev/null 2>&1
|
apt-get install -y curl >/dev/null 2>&1
|
||||||
fi
|
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
|
load_functions
|
||||||
|
|
||||||
# This function enables IPv6 if it's not disabled and sets verbose mode
|
# 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
|
$STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade
|
||||||
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
||||||
msg_ok "Updated Container OS"
|
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
|
# 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//')
|
systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//')
|
||||||
msg_ok "Customized Container"
|
msg_ok "Customized Container"
|
||||||
fi
|
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
|
chmod +x /usr/bin/update
|
||||||
if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then
|
if [[ -n "${SSH_AUTHORIZED_KEY}" ]]; then
|
||||||
mkdir -p /root/.ssh
|
mkdir -p /root/.ssh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user