Skip to content

Commit 8532da6

Browse files
authored
Glance: Use separate directory for configuration files (#14906)
* Refactor * FIX
1 parent bbd9b71 commit 8532da6

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

ct/glance.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,22 @@ function update_script() {
2929
msg_error "No ${APP} Installation Found!"
3030
exit
3131
fi
32+
if [[ ! -d /opt/glance_data ]]; then
33+
msg_info "Creating config directory"
34+
mkdir -p /opt/glance_data/
35+
cp /opt/glance/*.yml /opt/glance_data/
36+
sed -i 's|/opt/glance/glance\.yml|/opt/glance_data/glance.yml|' /etc/systemd/system/glance.service
37+
systemctl daemon-reload
38+
msg_ok "Created config directory"
39+
fi
40+
3241
if check_for_gh_release "glance" "glanceapp/glance"; then
3342
msg_info "Stopping Service"
3443
systemctl stop glance
3544
msg_ok "Stopped Service"
3645

37-
if [[ -f /opt/glance/glance.yml ]]; then
38-
msg_info "Backing up glance.yml"
39-
cp /opt/glance/glance.yml /tmp/glance.yml.bak
40-
msg_ok "Backed up glance.yml"
41-
fi
42-
4346
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "glance" "glanceapp/glance" "prebuild" "latest" "/opt/glance" "glance-linux-amd64.tar.gz"
4447

45-
if [[ -f /tmp/glance.yml.bak ]]; then
46-
msg_info "Restoring glance.yml"
47-
mv /tmp/glance.yml.bak /opt/glance/glance.yml
48-
msg_ok "Restored glance.yml"
49-
fi
50-
5148
msg_info "Starting Service"
5249
systemctl start glance
5350
msg_ok "Started Service"

install/glance-install.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ update_os
1616
fetch_and_deploy_gh_release "glance" "glanceapp/glance" "prebuild" "latest" "/opt/glance" "glance-linux-amd64.tar.gz"
1717

1818
msg_info "Configuring Glance"
19-
cat <<EOF >/opt/glance/glance.yml
19+
mkdir -p /opt/glance_data
20+
cat <<EOF >/opt/glance_data/glance.yml
2021
pages:
2122
- name: Startpage
2223
width: slim
@@ -39,22 +40,22 @@ EOF
3940
msg_ok "Configured Glance"
4041

4142
msg_info "Creating Service"
42-
service_path="/etc/systemd/system/glance.service"
43-
echo "[Unit]
43+
cat <<EOF >/etc/systemd/system/glance.service
44+
[Unit]
4445
Description=Glance Daemon
4546
After=network.target
4647
4748
[Service]
4849
Type=simple
4950
WorkingDirectory=/opt/glance
50-
ExecStart=/opt/glance/glance --config /opt/glance/glance.yml
51+
ExecStart=/opt/glance/glance --config /opt/glance_data/glance.yml
5152
TimeoutStopSec=20
5253
KillMode=process
5354
Restart=on-failure
5455
5556
[Install]
56-
WantedBy=multi-user.target" >$service_path
57-
57+
WantedBy=multi-user.target
58+
EOF
5859
systemctl enable -q --now glance
5960
msg_ok "Created Service"
6061

0 commit comments

Comments
 (0)