use new gh_release check, update logging

This commit is contained in:
Daniel Kukula 2025-09-07 14:29:10 +02:00
parent ec831b8c02
commit 3f5166ea10
2 changed files with 19 additions and 30 deletions

View File

@ -26,31 +26,28 @@ function update_script() {
if [[ ! -f /opt/livebook/.mix/escripts/livebook ]]; then if [[ ! -f /opt/livebook/.mix/escripts/livebook ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit 1 exit
fi fi
msg_info "Checking for updates..." if check_for_gh_release "livebook" "livebook-dev/livebook"; then
RELEASE=$(curl -fsSL https://api.github.com/repos/livebook-dev/livebook/releases/latest | grep "tag_name" | awk -F'"' '{print $4}') msg_info "Stopping ${APP}"
systemctl stop livebook
msg_info "Service stopped"
if [[ "${RELEASE}" != "$(cat /opt/livebook/.livebook 2>/dev/null)" ]]; then msg_info "Updating container"
msg_info "Updating ${APP} LXC"
$STD apt-get update $STD apt-get update
$STD apt-get -y upgrade $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 source /opt/livebook/.env
cd /opt/livebook || exit 1 cd /opt/livebook
$STD mix escript.install hex livebook --force $STD mix escript.install hex livebook --force
echo "$RELEASE" | $STD tee /opt/livebook/.livebook
chown -R livebook:livebook /opt/livebook /data chown -R livebook:livebook /opt/livebook /data
systemctl start livebook
msg_ok "Successfully updated to ${RELEASE}" msg_ok "Updated ${APP}"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}."
fi fi
exit exit
} }
@ -58,7 +55,6 @@ start
build_container build_container
description description
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}:8080${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}"

View File

@ -30,14 +30,14 @@ msg_info "Installing Erlang and Elixir"
mkdir -p /opt/livebook /data mkdir -p /opt/livebook /data
export HOME=/opt/livebook export HOME=/opt/livebook
cd /opt/livebook || exit 1 cd /opt/livebook
curl -fsSO https://elixir-lang.org/install.sh curl -fsSO https://elixir-lang.org/install.sh
$STD sh install.sh elixir@latest otp@latest $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) ERLANG_VERSION=$(ls /opt/livebook/.elixir-install/installs/otp/ | head -n1)
ELIXIR_VERSION=$(ls /opt/livebook/.elixir-install/installs/elixir/ | 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 ERLANG_BIN="/opt/livebook/.elixir-install/installs/otp/$ERLANG_VERSION/bin"
export ELIXIR_BIN="/opt/livebook/.elixir-install/installs/elixir/$ELIXIR_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 local.rebar --force
$STD mix escript.install hex livebook --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 <<EOF > /opt/livebook/livebook.creds
Livebook-Credentials
Livebook Password: $LIVEBOOK_PASSWORD
EOF
msg_ok "Livebook password stored in /opt/livebook/livebook.creds"
cat <<EOF > /opt/livebook/.env cat <<EOF > /opt/livebook/.env
export HOME=/opt/livebook export HOME=/opt/livebook
export LIVEBOOK_VERSION=$RELEASE
export ERLANG_VERSION=$ERLANG_VERSION export ERLANG_VERSION=$ERLANG_VERSION
export ELIXIR_VERSION=$ELIXIR_VERSION export ELIXIR_VERSION=$ELIXIR_VERSION
export LIVEBOOK_PORT=8080 export LIVEBOOK_PORT=8080
@ -93,14 +83,17 @@ RestartSec=5
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
msg_info "Setting ownership and permissions"
chown -R livebook:livebook /opt/livebook /data chown -R livebook:livebook /opt/livebook /data
msg_ok "Set ownership and permissions"
systemctl enable -q --now livebook systemctl enable -q --now livebook
msg_ok "Installed Livebook" msg_ok "Installed Livebook"
msg_ok "Installation completed successfully" msg_info "Saving Livebook credentials"
cat <<EOF > /opt/livebook/livebook.creds
Livebook-Credentials
Livebook Password: $LIVEBOOK_PASSWORD
EOF
msg_ok "Livebook password stored in /opt/livebook/livebook.creds"
motd_ssh motd_ssh
customize customize