mirror of
https://github.com/community-scripts/ProxmoxVED.git
synced 2026-02-26 05:55:54 +00:00
run as livebook user
This commit is contained in:
@@ -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 <<EOF > /opt/livebook.creds
|
||||
Livebook-Credentials
|
||||
Livebook Password: $LIVEBOOK_PASSWORD
|
||||
EOF
|
||||
|
||||
cat <<EOF > /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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user