Skip to content

Commit a1e3ae6

Browse files
authored
Fix wikijs (#3232)
1 parent f031dcb commit a1e3ae6

File tree

2 files changed

+47
-41
lines changed

2 files changed

+47
-41
lines changed

ct/wikijs.sh

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,50 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30-
msg_info "Stopping ${APP}"
31-
systemctl stop wikijs
32-
msg_ok "Stopped ${APP}"
30+
RELEASE=$(curl -s https://api.github.com/repos/Requarks/wiki/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31+
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
32+
msg_info "Verifying whether ${APP}' new release is v3.x+ and current install uses SQLite."
33+
SQLITE_INSTALL=$([ -f /opt/wikijs/db.sqlite ] && echo "true" || echo "false")
34+
if [[ "${SQLITE_INSTALL}" == "true" && "${RELEASE}" =~ ^3.* ]]; then
35+
echo "SQLite is not supported in v3.x+, currently there is no update path availble."
36+
exit
37+
fi
38+
msg_ok "There is an update path available for ${APP} to v${RELEASE}"
3339

34-
msg_info "Backing up Data"
35-
rm -rf ~/data-backup
36-
mkdir -p ~/data-backup
37-
[ -f /opt/wikijs/db.sqlite ] && cp /opt/wikijs/db.sqlite ~/data-backup
38-
[ -f /opt/wikijs/config.yml ] && cp /opt/wikijs/config.yml ~/data-backup
39-
[ -d /opt/wikijs/data ] && cp -R /opt/wikijs/data ~/data-backup
40-
msg_ok "Backed up Data"
40+
msg_info "Stopping ${APP}"
41+
systemctl stop wikijs
42+
msg_ok "Stopped ${APP}"
4143

42-
msg_info "Updating ${APP}"
43-
rm -rf /opt/wikijs/*
44-
cd /opt/wikijs
45-
wget -q https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz
46-
tar xzf wiki-js.tar.gz
47-
msg_ok "Updated ${APP}"
44+
msg_info "Backing up Data"
45+
mkdir /opt/wikijs-backup
46+
$SQLITE_INSTALL && cp /opt/wikijs/db.sqlite /opt/wikijs-backup
47+
cp -R /opt/wikijs/{config.yml,/data} /opt/wikijs-backup
48+
msg_ok "Backed up Data"
4849

49-
msg_info "Restoring Data"
50-
cp -R ~/data-backup/* /opt/wikijs
51-
rm -rf ~/data-backup
52-
$STD npm rebuild sqlite3
53-
msg_ok "Restored Data"
50+
msg_info "Updating ${APP}"
51+
rm -rf /opt/wikijs/*
52+
cd /opt/wikijs
53+
wget -q "https://github.com/requarks/wiki/releases/download/v${RELEASE}/wiki-js.tar.gz"
54+
tar -xzf wiki-js.tar.gz
55+
msg_ok "Updated ${APP}"
5456

55-
msg_info "Starting ${APP}"
56-
systemctl start wikijs
57-
msg_ok "Started ${APP}"
58-
msg_ok "Updated Successfully"
57+
msg_info "Restoring Data"
58+
cp -R /opt/wikijs-backup/* /opt/wikijs
59+
$SQLITE_INSTALL && $STD npm rebuild sqlite3
60+
msg_ok "Restored Data"
61+
62+
msg_info "Starting ${APP}"
63+
systemctl start wikijs
64+
msg_ok "Started ${APP}"
65+
66+
msg_info "Cleaning Up"
67+
rm -rf /opt/wikijs/wiki-js.tar.gz
68+
rm -rf /opt/wikijs-backup
69+
msg_ok "Cleanup Completed"
70+
msg_ok "Updated Successfully"
71+
else
72+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
73+
fi
5974
exit
6075
}
6176

@@ -66,4 +81,4 @@ description
6681
msg_ok "Completed Successfully!\n"
6782
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
6883
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
69-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
84+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"

install/wikijs-install.sh

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ $STD apt-get install -y \
1919
sudo \
2020
mc \
2121
git \
22-
ca-certificates \
23-
gnupg \
24-
build-essential \
25-
python3 \
26-
g++ \
27-
make
22+
gpg
2823
msg_ok "Installed Dependencies"
2924

3025
msg_info "Setting up Node.js Repository"
@@ -67,16 +62,12 @@ msg_ok "Set up PostgreSQL"
6762
msg_info "Setup Wiki.js"
6863
temp_file=$(mktemp)
6964
RELEASE=$(curl -s https://api.github.com/repos/Requarks/wiki/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
70-
wget -q "https://github.com/Requarks/wiki/archive/refs/tags/v${RELEASE}.tar.gz" -O "$temp_file"
71-
tar -xzf "$temp_file"
72-
mv wiki-${RELEASE} /opt/wikijs
65+
wget -q "https://github.com/requarks/wiki/releases/download/v${RELEASE}/wiki-js.tar.gz" -O "$temp_file"
66+
mkdir /opt/wikijs
67+
tar -xzf "$temp_file" -C /opt/wikijs
7368
mv /opt/wikijs/config.sample.yml /opt/wikijs/config.yml
7469
sed -i -E 's|^( *user: ).*|\1'"$DB_USER"'|' /opt/wikijs/config.yml
7570
sed -i -E 's|^( *pass: ).*|\1'"$DB_PASS"'|' /opt/wikijs/config.yml
76-
cd /opt/wikijs
77-
export NODE_OPTIONS="--max-old-space-size=2048"
78-
$STD yarn install --ignore-engines
79-
$STD yarn build
8071
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
8172
msg_ok "Installed Wiki.js"
8273

@@ -88,7 +79,7 @@ After=network.target
8879
8980
[Service]
9081
Type=simple
91-
ExecStart=/usr/bin/yarn start
82+
ExecStart=/usr/bin/node server
9283
Restart=always
9384
User=root
9485
Environment=NODE_ENV=production
@@ -107,4 +98,4 @@ msg_info "Cleaning up"
10798
rm -f "$temp_file"
10899
$STD apt-get -y autoremove
109100
$STD apt-get -y autoclean
110-
msg_ok "Cleaned"
101+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)