Skip to content

Commit cabcdc2

Browse files
authored
Installation and update fixes (#3895)
1 parent e8e4748 commit cabcdc2

File tree

2 files changed

+48
-43
lines changed

2 files changed

+48
-43
lines changed

ct/outline.sh

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,48 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
26-
if [[ ! -d /opt/outline ]]; then
27-
msg_error "No ${APP} Installation Found!"
28-
exit
29-
fi
30-
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-
msg_info "Stopping Services"
33-
systemctl stop outline
34-
msg_ok "Services Stopped"
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [[ ! -d /opt/outline ]]; then
27+
msg_error "No ${APP} Installation Found!"
28+
exit
29+
fi
30+
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+
msg_info "Stopping Services"
33+
systemctl stop outline
34+
msg_ok "Services Stopped"
3535

36-
msg_info "Updating ${APP} to ${RELEASE}"
37-
temp_file=$(mktemp)
38-
rm -rf /opt/outline/node_modules
39-
curl -fsSL "https://github.com/outline/outline/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
40-
tar zxf $temp_file
41-
cp -rf outline-${RELEASE}/* /opt/outline
42-
cd /opt/outline
43-
export NODE_OPTIONS="--max-old-space-size=3584"
44-
$STD yarn install --frozen-lockfile
45-
$STD yarn build
46-
echo "${RELEASE}" >/opt/${APP}_version.txt
47-
msg_ok "Updated ${APP}"
36+
msg_info "Updating ${APP} to ${RELEASE}"
37+
temp_file=$(mktemp)
38+
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
43+
cd /opt/outline || exit
44+
export NODE_ENV=development
45+
export NODE_OPTIONS="--max-old-space-size=3584"
46+
$STD yarn install --frozen-lockfile
47+
$STD yarn build
48+
mv /opt/.env /opt/outline
49+
echo "${RELEASE}" >/opt/${APP}_version.txt
50+
msg_ok "Updated ${APP}"
4851

49-
msg_info "Starting Services"
50-
systemctl start outline
51-
msg_ok "Started Services"
52+
msg_info "Starting Services"
53+
systemctl start outline
54+
msg_ok "Started Services"
5255

53-
msg_info "Cleaning Up"
54-
rm -rf $temp_file
55-
rm -rf $HOME/outline-${RELEASE}
56-
msg_ok "Cleaned"
57-
msg_ok "Updated Successfully"
58-
else
59-
msg_ok "No update required. ${APP} is already at ${RELEASE}"
60-
fi
61-
exit
56+
msg_info "Cleaning Up"
57+
rm -rf "$temp_file"
58+
rm -rf "$HOME"/outline-"${RELEASE}"
59+
msg_ok "Cleaned"
60+
msg_ok "Updated Successfully"
61+
else
62+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
63+
fi
64+
exit
6265
}
6366

6467
start
@@ -68,4 +71,4 @@ description
6871
msg_ok "Completed Successfully!\n"
6972
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
7073
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
71-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
74+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"

install/outline-install.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ update_os
1515

1616
msg_info "Installing Dependencies"
1717
$STD apt-get install -y \
18-
gnupg \
19-
mkcert \
20-
git \
21-
redis
18+
gnupg \
19+
mkcert \
20+
git \
21+
redis
2222
msg_ok "Installed Dependencies"
2323

2424
msg_info "Setting up Node.js Repository"
@@ -43,7 +43,6 @@ $STD apt-get install -y postgresql-16
4343
DB_NAME="outline"
4444
DB_USER="outline"
4545
DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)"
46-
SECRET_KEY="$(openssl rand -hex 32)"
4746
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
4847
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;"
4948
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
@@ -52,6 +51,7 @@ $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';"
5251
msg_ok "Set up PostgreSQL"
5352

5453
msg_info "Setup Outline (Patience)"
54+
SECRET_KEY="$(openssl rand -hex 32)"
5555
temp_file=$(mktemp)
5656
LOCAL_IP="$(hostname -I | awk '{print $1}')"
5757
RELEASE=$(curl -fsSL https://api.github.com/repos/outline/outline/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
@@ -60,6 +60,7 @@ tar zxf $temp_file
6060
mv outline-${RELEASE} /opt/outline
6161
cd /opt/outline
6262
cp .env.sample .env
63+
export NODE_ENV=development
6364
sed -i 's/NODE_ENV=production/NODE_ENV=development/g' /opt/outline/.env
6465
sed -i "s/generate_a_new_key/${SECRET_KEY}/g" /opt/outline/.env
6566
sed -i "s/user:pass@postgres/${DB_USER}:${DB_PASS}@localhost/g" /opt/outline/.env
@@ -70,6 +71,7 @@ $STD yarn install --frozen-lockfile
7071
export NODE_OPTIONS="--max-old-space-size=3584"
7172
$STD yarn build
7273
sed -i 's/NODE_ENV=development/NODE_ENV=production/g' /opt/outline/.env
74+
export NODE_ENV=production
7375
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
7476
msg_ok "Setup Outline"
7577

@@ -83,7 +85,7 @@ After=network.target
8385
Type=simple
8486
User=root
8587
WorkingDirectory=/opt/outline
86-
ExecStart=/usr/bin/node ./build/server/index.js
88+
ExecStart=/usr/bin/yarn start
8789
Restart=always
8890
EnvironmentFile=/opt/outline/.env
8991

0 commit comments

Comments
 (0)