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