1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-22 15:20:09 +01:00

Removed copy step in entrypoint.sh

Tested updating, works as long as presistent files are compatible.
This commit is contained in:
Daan 2024-10-24 00:09:27 +02:00
parent 4902b5f351
commit ba5ba2f1d6
2 changed files with 19 additions and 32 deletions

View File

@ -24,11 +24,9 @@ ENV WGDASH=/opt/wireguarddashboard
# Removing the Linux Image package to preserve space on the image, for this reason also deleting apt lists, to be able to install packages: run apt update. # Removing the Linux Image package to preserve space on the image, for this reason also deleting apt lists, to be able to install packages: run apt update.
# Doing WireGuard Dashboard installation measures. Modify the git clone command to get the preferred version, with a specific branch for example. # Doing WireGuard Dashboard installation measures. Modify the git clone command to get the preferred version, with a specific branch for example.
RUN mkdir -p /setup/conf \ RUN mkdir -p /data/conf \
&& mkdir /setup/app \ && mkdir -p ${WGDASH}/src
&& mkdir ${WGDASH} \ COPY ./src ${WGDASH}/src
&& mkdir /data
COPY ./src /setup/app/src
# Set the volume to be used for WireGuard configuration persistency. Can be ignored so it does not create volumes when not specified. # Set the volume to be used for WireGuard configuration persistency. Can be ignored so it does not create volumes when not specified.
#VOLUME /etc/wireguard #VOLUME /etc/wireguard
@ -47,8 +45,8 @@ PreDown = iptables -t nat -D POSTROUTING -s ${wg_net}/24 -o ${out_adapt} -j MASQ
PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP\n\ PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP\n\
ListenPort = ${wg_port}\n\ ListenPort = ${wg_port}\n\
SaveConfig = true\n\ SaveConfig = true\n\
DNS = ${global_dns}" > /setup/conf/wg0.conf \ DNS = ${global_dns}" > /data/conf/wg0.conf \
&& chmod 600 /setup/conf/wg0.conf && chmod 600 /data/conf/wg0.conf
# Defining a way for Docker to check the health of the container. In this case: checking the login URL. # Defining a way for Docker to check the health of the container. In this case: checking the login URL.
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \

View File

@ -5,42 +5,32 @@ echo "Starting the WireGuard Dashboard Docker container."
ensure_installation() { ensure_installation() {
# When using a custom directory to store the files, this part moves over and makes sure the installation continues. # When using a custom directory to store the files, this part moves over and makes sure the installation continues.
echo "Checking if everything is present." echo "Quick-installing..."
if [ -z "$(ls -A "${WGDASH}")" ]; then # [ ! -f "/data/wg-dashboard.ini" ] && [ ! -d "/data/db" ] [ ! -d "/data/db" ] && echo "Creating database dir" && mkdir /data/db
echo "Detected empty directory, moving over..." ln -s /data/db "${WGDASH}/src/db"
# Moving over source files. (This does not include src/db and src/wg-dashboard.ini folder and file.) [ ! -f "/data/wg-dashboard.ini" ] && echo "Creating wg-dashboard.ini file" && touch /data/wg-dashboard.ini
mv -v /setup/app/* "${WGDASH}" ln -s /data/wg-dashboard.ini "${WGDASH}/src/wg-dashboard.ini"
[ ! -d "/data/db" ] && echo "Creating database dir" && mkdir /data/db python3 -m venv "${WGDASH}"/src/venv
ln -s /data/db "${WGDASH}/src/db" . "${WGDASH}/src/venv/bin/activate"
[ ! -f "/data/wg-dashboard.ini" ] && echo "Creating wg-dashboard.ini file" && touch /data/wg-dashboard.ini mv /usr/lib/python3.12/site-packages/psutil* "${WGDASH}"/src/venv/lib/python3.12/site-packages
ln -s /data/wg-dashboard.ini "${WGDASH}/src/wg-dashboard.ini" mv /usr/lib/python3.12/site-packages/bcrypt* "${WGDASH}"/src/venv/lib/python3.12/site-packages
chmod +x "${WGDASH}"/src/wgd.sh
cd "${WGDASH}"/src || exit
./wgd.sh install
python3 -m venv "${WGDASH}"/src/venv echo "Looks like the installation succeeded."
. "${WGDASH}/src/venv/bin/activate"
mv /usr/lib/python3.12/site-packages/psutil* "${WGDASH}"/src/venv/lib/python3.12/site-packages
mv /usr/lib/python3.12/site-packages/bcrypt* "${WGDASH}"/src/venv/lib/python3.12/site-packages
chmod +x "${WGDASH}"/src/wgd.sh
cd "${WGDASH}"/src || exit
./wgd.sh install
echo "Looks like the installation succesfully moved over."
else
echo "Looks like everything is present. Or the directory is not empty."
fi
# This first step is to ensure the wg0.conf file exists, and if not, then its copied over from the ephemeral container storage. # This first step is to ensure the wg0.conf file exists, and if not, then its copied over from the ephemeral container storage.
# This is done so WGDashboard it works out of the box # This is done so WGDashboard it works out of the box
if [ ! -f "/etc/wireguard/wg0.conf" ]; then if [ ! -f "/etc/wireguard/wg0.conf" ]; then
echo "Standard wg0 Configuration file not found, grabbing template." echo "Standard wg0 Configuration file not found, grabbing template."
cp -a "/setup/conf/wg0.conf" "/etc/wireguard/wg0.conf" cp -a "/data/conf/wg0.conf" "/etc/wireguard/wg0.conf"
echo "Setting a secure private key." # SORRY 4 BE4 - Daan echo "Setting a secure private key." # SORRY 4 BE4 - Daan
@ -89,7 +79,6 @@ clean_up() {
echo "Removed unneeded logs!" echo "Removed unneeded logs!"
} }
set_envvars() { set_envvars() {
printf "\n------------- SETTING ENVIRONMENT VARIABLES ----------------\n" printf "\n------------- SETTING ENVIRONMENT VARIABLES ----------------\n"