Skip to content

Commit 661a58a

Browse files
authored
Refactor (#5876)
1 parent acc500f commit 661a58a

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

ct/gitea.sh

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,33 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
26-
if [[ ! -f /usr/local/bin/gitea ]]; then
27-
msg_error "No ${APP} Installation Found!"
28-
exit
29-
fi
30-
RELEASE=$(curl -fsSL https://github.com/go-gitea/gitea/releases/latest | grep "title>Release" | cut -d " " -f 4 | sed 's/^v//')
31-
msg_info "Updating $APP to ${RELEASE}"
32-
FILENAME="gitea-$RELEASE-linux-amd64"
33-
curl -fsSL "https://github.com/go-gitea/gitea/releases/download/v$RELEASE/gitea-$RELEASE-linux-amd64" -o $FILENAME
34-
systemctl stop gitea
35-
rm -rf /usr/local/bin/gitea
36-
mv $FILENAME /usr/local/bin/gitea
37-
chmod +x /usr/local/bin/gitea
38-
systemctl start gitea
39-
msg_ok "Updated $APP Successfully"
40-
exit
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
27+
if [[ ! -f /usr/local/bin/gitea ]]; then
28+
msg_error "No ${APP} Installation Found!"
29+
exit
30+
fi
31+
RELEASE=$(curl -fsSL https://github.com/go-gitea/gitea/releases/latest | grep "title>Release" | cut -d " " -f 4 | sed 's/^v//')
32+
if [[ "${RELEASE}" != "$(cat ~/.gitea 2>/dev/null)" ]] || [[ ! -f ~/.gitea ]]; then
33+
msg_info "Stopping service"
34+
systemctl stop gitea
35+
msg_ok "Service stopped"
36+
37+
rm -rf /usr/local/bin/gitea
38+
fetch_and_deploy_gh_release "gitea" "go-gitea/gitea" "singlefile" "latest" "/usr/local/bin" "gitea-*-linux-amd64"
39+
chmod +x /usr/local/bin/gitea
40+
41+
msg_info "Starting service"
42+
systemctl start gitea
43+
msg_ok "Started service"
44+
45+
msg_ok "Update Successful"
46+
else
47+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
48+
fi
49+
exit
4150
}
4251

4352
start

install/gitea-install.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ $STD apt-get install -y git
1919
$STD apt-get install -y sqlite3
2020
msg_ok "Installed Dependencies"
2121

22-
msg_info "Installing Gitea"
23-
RELEASE=$(curl -fsSL https://github.com/go-gitea/gitea/releases/latest | grep "title>Release" | cut -d " " -f 4 | sed 's/^v//')
24-
curl -fsSL "https://github.com/go-gitea/gitea/releases/download/v$RELEASE/gitea-$RELEASE-linux-amd64" -o "gitea-$RELEASE-linux-amd64"
25-
mv gitea* /usr/local/bin/gitea
22+
fetch_and_deploy_gh_release "gitea" "go-gitea/gitea" "singlefile" "latest" "/usr/local/bin" "gitea-*-linux-amd64"
23+
24+
msg_info "Configuring Gitea"
2625
chmod +x /usr/local/bin/gitea
2726
adduser --system --group --disabled-password --shell /bin/bash --home /etc/gitea gitea >/dev/null
2827
mkdir -p /var/lib/gitea/{custom,data,log}
@@ -31,7 +30,7 @@ chmod -R 750 /var/lib/gitea/
3130
chown root:gitea /etc/gitea
3231
chmod 770 /etc/gitea
3332
sudo -u gitea ln -s /var/lib/gitea/data/.ssh/ /etc/gitea/.ssh
34-
msg_ok "Installed Gitea"
33+
msg_ok "Configured Gitea"
3534

3635
msg_info "Creating Service"
3736
cat <<EOF >/etc/systemd/system/gitea.service

0 commit comments

Comments
 (0)