Skip to content

Commit 654bd1f

Browse files
authored
Refactor (#6424)
1 parent b6bd8a6 commit 654bd1f

2 files changed

Lines changed: 12 additions & 21 deletions

File tree

ct/outline.sh

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,32 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30+
3031
RELEASE=$(curl -fsSL https://api.github.com/repos/outline/outline/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
32+
if [[ ! -f ~/.outline ]] || [[ "${RELEASE}" != "$(cat ~/.outline)" ]]; then
3233
msg_info "Stopping Services"
3334
systemctl stop outline
3435
msg_ok "Services Stopped"
3536

36-
msg_info "Updating ${APP} to ${RELEASE}"
37-
temp_file=$(mktemp)
37+
msg_info "Creating backup"
3838
cp /opt/outline/.env /opt
39-
rm -rf /opt/outline
40-
curl -fsSL "https://github.com/outline/outline/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
41-
tar zxf "$temp_file"
42-
mv outline-"${RELEASE}" /opt/outline
39+
msg_ok "Backup created"
40+
41+
fetch_and_deploy_gh_release "outline" "outline/outline" "tarball"
42+
43+
msg_info "Updating ${APP} to ${RELEASE}"
4344
cd /opt/outline
4445
export NODE_ENV=development
4546
export NODE_OPTIONS="--max-old-space-size=3584"
4647
$STD yarn install --frozen-lockfile
4748
$STD yarn build
4849
mv /opt/.env /opt/outline
49-
echo "${RELEASE}" >/opt/${APP}_version.txt
5050
msg_ok "Updated ${APP}"
5151

5252
msg_info "Starting Services"
5353
systemctl start outline
5454
msg_ok "Started Services"
5555

56-
msg_info "Cleaning Up"
57-
rm -rf "$temp_file"
58-
rm -rf "$HOME"/outline-"${RELEASE}"
59-
msg_ok "Cleaned"
6056
msg_ok "Updated Successfully"
6157
else
6258
msg_ok "No update required. ${APP} is already at ${RELEASE}"

install/outline-install.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@ $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';"
4040
} >>~/outline.creds
4141
msg_ok "Set up PostgreSQL Database"
4242

43-
msg_info "Setup Outline (Patience)"
43+
fetch_and_deploy_gh_release "outline" "outline/outline" "tarball"
44+
45+
msg_info "Configuring Outline (Patience)"
4446
SECRET_KEY="$(openssl rand -hex 32)"
45-
temp_file=$(mktemp)
4647
LOCAL_IP="$(hostname -I | awk '{print $1}')"
47-
RELEASE=$(curl -fsSL https://api.github.com/repos/outline/outline/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
48-
curl -fsSL "https://github.com/outline/outline/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
49-
tar zxf $temp_file
50-
mv outline-${RELEASE} /opt/outline
5148
cd /opt/outline
5249
cp .env.sample .env
5350
export NODE_ENV=development
@@ -62,8 +59,7 @@ export NODE_OPTIONS="--max-old-space-size=3584"
6259
$STD yarn build
6360
sed -i 's/NODE_ENV=development/NODE_ENV=production/g' /opt/outline/.env
6461
export NODE_ENV=production
65-
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
66-
msg_ok "Setup Outline"
62+
msg_ok "Configured Outline"
6763

6864
msg_info "Creating Service"
6965
cat <<EOF >/etc/systemd/system/outline.service
@@ -89,7 +85,6 @@ motd_ssh
8985
customize
9086

9187
msg_info "Cleaning up"
92-
rm -rf $temp_file
9388
$STD apt-get -y autoremove
9489
$STD apt-get -y autoclean
9590
msg_ok "Cleaned"

0 commit comments

Comments
 (0)