Skip to content

Commit ddc238c

Browse files
committed
Refactor postinst and package-deb.sh to use SPINUP_ROOT_DIR variable for consistency
1 parent d276103 commit ddc238c

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

packaging/DEBIAN/postinst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
SPINUP_ROOT_DIR="/etc/spinup"
4+
35
# Make sure the script is being run as root
46
if [ "$(id -u)" -ne 0 ]; then
57
echo "This script must be run as root" >&2
@@ -20,17 +22,17 @@ fi
2022
#####################
2123

2224
# Create the spinup directory if it doesn't exist
23-
mkdir -p /etc/spinup
25+
mkdir -p "$SPINUP_ROOT_DIR"
2426

2527
# Create the config directory if it doesn't exist
26-
mkdir -p /etc/spinup/config
28+
mkdir -p "$SPINUP_ROOT_DIR/config"
2729

2830
# Remove the old symlink if it exists and create a new one
2931
rm -f /usr/bin/spinup
30-
ln -s /etc/spinup/bin/spinup /usr/bin/spinup
32+
ln -s "$SPINUP_ROOT_DIR/bin/spinup" /usr/bin/spinup
3133

3234
# Set the correct permissions on the spinup directory
33-
chown -R root:root /etc/spinup
35+
chown -R root:root "$SPINUP_ROOT_DIR"
3436

3537
###############
3638
### Dnsmasq ###
@@ -42,15 +44,15 @@ mkdir -p /etc/dnsmasq.d
4244
# Check if the spinup.conf already exists in the dnsmasq.d directory
4345
if [ ! -f /etc/dnsmasq.d/spinup.conf ]; then
4446
# Link the dnsmasq configuration file for spinup to the dnsmasq.d directory if it doesn't exist
45-
ln -s /etc/spinup/config/dnsmasq.conf /etc/dnsmasq.d/spinup.conf
47+
ln -s "$SPINUP_ROOT_DIR/config/dnsmasq.conf" /etc/dnsmasq.d/spinup.conf
4648
fi
4749

4850
#############
4951
### Nginx ###
5052
#############
5153

5254
USER_SPINUP_NGINX_DIR="$USER_HOME/.config/spinup/nginx"
53-
SPINUP_NGINX_DIR="/etc/spinup/config/nginx"
55+
SPINUP_NGINX_DIR="$SPINUP_ROOT_DIR/config/nginx"
5456

5557
# Create the user's spinup nginx directory if it doesn't exist
5658
mkdir -p $USER_SPINUP_NGINX_DIR

scripts/release/package-deb.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env bash
22

3+
SPINUP_ROOT_DIR="/etc/spinup"
34
SPINUP_VERSION=$(cat ./common/.version | sed 's/^v//')
45

56
for os_version in "" "-ubuntu24.04"; do
67
# Create the directory structure for the .deb package
78
mkdir -p deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN
8-
mkdir -p deb/spinup-${SPINUP_VERSION}${os_version}/etc/spinup/bin
9+
mkdir -p deb/spinup-${SPINUP_VERSION}${os_version}${SPINUP_ROOT_DIR}/bin
910

1011
# Copy the necessary files to the .deb package directory
11-
cp build/bin/spinup-${SPINUP_VERSION}${os_version} deb/spinup-${SPINUP_VERSION}${os_version}/etc/spinup/bin/spinup
12+
cp build/bin/spinup-${SPINUP_VERSION}${os_version} deb/spinup-${SPINUP_VERSION}${os_version}${SPINUP_ROOT_DIR}/bin/spinup
1213
cp packaging/DEBIAN/* deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN
1314
cp -r packaging/unix/usr deb/spinup-${SPINUP_VERSION}${os_version}
1415
cp -r packaging/unix/etc deb/spinup-${SPINUP_VERSION}${os_version}

0 commit comments

Comments
 (0)