address code review comments and suggestions

This commit is contained in:
Dominik Siebel 2024-12-03 22:13:51 +01:00
parent ce3aca46d9
commit 3222f03203
No known key found for this signature in database
2 changed files with 17 additions and 30 deletions

View File

@ -56,31 +56,27 @@ function update_script() {
header_info
check_container_storage
check_container_resources
service_path="/etc/systemd/system/silverbullet.service"
if [[ ! -d /opt/silverbullet || ! -f "${service_path}" ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
if [[ ! -d /opt/silverbullet ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
RELEASE=$(curl -s https://api.github.com/repos/silverbulletmd/silverbullet/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
if [[ ! -f "/opt/silverbullet/${APP}_version.txt" || "${RELEASE}" != "$(cat /opt/silverbullet/${APP}_version.txt)" ]]; then
if [[ ! -f "/opt/${APP}_version.txt" || "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Stopping ${APP}"
systemctl stop silverbullet.service
systemctl stop silverbullet
msg_ok "Stopped ${APP}"
msg_info "Updating ${APP} to ${RELEASE}"
msg_info "Updating ${APP} to v${RELEASE}"
wget -q https://github.com/silverbulletmd/silverbullet/releases/download/${RELEASE}/silverbullet-server-linux-x86_64.zip
unzip silverbullet-server-linux-x86_64.zip &>/dev/null
mv silverbullet /opt/silverbullet/bin/
chmod +x /opt/silverbullet/bin/silverbullet
ln -sf /opt/silverbullet/bin/silverbullet /usr/local/bin/silverbullet
echo "${RELEASE}" >/opt/silverbullet/${APP}_version.txt
msg_ok "Updated ${APP}"
msg_info "Starting ${APP}"
systemctl start silverbullet.service
systemctl start silverbullet
sleep 1
if systemctl status silverbullet.service &>/dev/null ; then
if systemctl status silverbullet &>/dev/null ; then
msg_ok "Started ${APP}"
msg_ok "Updated Successfully"
msg_ok "Updated ${APP} to v${RELEASE}"
else
msg_error "Failed to start ${APP}"
fi

View File

@ -14,9 +14,10 @@ network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y curl
$STD apt-get install -y sudo
$STD apt-get install -y mc
$STD apt-get install -y \
curl \
sudo \
mc
msg_ok "Installed Dependencies"
RELEASE=$(curl -s https://api.github.com/repos/silverbulletmd/silverbullet/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
@ -24,17 +25,15 @@ RELEASE=$(curl -s https://api.github.com/repos/silverbulletmd/silverbullet/relea
msg_info "Installing ${APPLICATION}"
mkdir -p /opt/silverbullet/bin /opt/silverbullet/space
wget -q https://github.com/silverbulletmd/silverbullet/releases/download/${RELEASE}/silverbullet-server-linux-x86_64.zip
unzip silverbullet-server-linux-x86_64.zip &>/dev/null
mv silverbullet /opt/silverbullet/bin/
unzip -q -d /opt/silverbullet/bin/ silverbullet-server-linux-x86_64.zip
chmod +x /opt/silverbullet/bin/silverbullet
ln -s /opt/silverbullet/bin/silverbullet /usr/local/bin/silverbullet
echo "${RELEASE}" >/opt/silverbullet/${APPLICATION}_version.txt
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed ${APPLICATION}"
msg_info "Creating Service"
service_path="/etc/systemd/system/silverbullet.service"
echo "[Unit]
cat <<EOF >/etc/systemd/system/silverbullet.service
[Unit]
Description=Silverbullet Daemon
After=syslog.target network.target
@ -46,19 +45,11 @@ WorkingDirectory=/opt/silverbullet
Restart=on-failure
[Install]
WantedBy=multi-user.target" >$service_path
WantedBy=multi-user.target
EOF
systemctl enable --now -q silverbullet
msg_ok "Created Service"
msg_info "Starting ${APPLICATION}"
systemctl start silverbullet.service
sleep 1
if systemctl status silverbullet.service &>/dev/null ; then
msg_ok "Started ${APPLICATION}"
else
msg_error "Failed to start ${APPLICATION}"
fi
motd_ssh
customize