Skip to content
This repository was archived by the owner on May 19, 2024. It is now read-only.

Commit b1b844a

Browse files
authored
Fix log handling in bash (#74)
* Fix logging to console * Replace `username` with `user` * Fix how log handling in bash * Fix directory errors * Tail command needs to run in the background * Remove log directory * Fix brave errors * Run child bash scripts in the back * Fix echo * Fix brave example
1 parent 0df9df0 commit b1b844a

File tree

8 files changed

+51
-81
lines changed

8 files changed

+51
-81
lines changed

docker/base/Dockerfile

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,9 @@ RUN apt-get update; \
7575
#
7676
#make directories for warp
7777
#
78-
mkdir -p /etc/warp /certs/ /media/ /usr/bin/warp /etc/warp/entrypoint.d/;\
79-
chmod 1777 /certs/; \
80-
chmod 1777 /media/; \
81-
chmod 1777 /usr/bin/warp; \
82-
chmod 1777 /etc/warp/entrypoint.d/; \
83-
chown ${USERNAME} /certs/; \
84-
chown ${USERNAME} /usr/bin/warp/; \
85-
chown ${USERNAME} /etc/warp/entrypoint.d/; \
86-
chown ${USERNAME} /media/; \
78+
mkdir -p /etc/warp /certs /media /usr/bin/warp /etc/warp/entrypoint.d;\
79+
chmod 1777 /certs /media /usr/bin/warp /etc/warp/entrypoint.d; \
80+
chown ${USERNAME} /certs /usr/bin/warp /etc/warp/entrypoint.d /media; \
8781
chown -R $USERNAME:$USERNAME /home/${USERNAME}
8882

8983
#
@@ -107,9 +101,6 @@ ENTRYPOINT [ "/usr/bin/tini","--" ]
107101
COPY docker/base/entrypoint.sh /etc/warp/entrypoint.sh
108102
RUN chmod +x /etc/warp/entrypoint.sh
109103

110-
COPY docker/base/run-bash.sh /etc/warp/run-bash.sh
111-
RUN chmod +x /etc/warp/run-bash.sh
112-
113104
COPY docker/base/generate-certs.sh /certs/generate-certs.sh
114105
RUN chmod +x /certs/generate-certs.sh
115106

docker/base/entrypoint.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -xeo pipefail
44

5-
trap 'trap " " SIGINT; kill -SIGINT 0; wait;' SIGINT SIGTERM
5+
trap '[[ -n $(jobs -p) ]] && kill $(jobs -p); echo "Error: Warp failed with exit code $?" >&2; [[ -n $(jobs -p) ]] && wait $(jobs -p); exit $?' ERR
66

77
#Start dbus for pulseaudio
88
sudo /etc/init.d/dbus start
@@ -21,19 +21,37 @@ pacmd set-default-sink vsink
2121
pacmd set-default-source vsink.monitor
2222

2323
#Start ffmpeg
24-
source /etc/warp/ffmpeg.sh &
24+
source /etc/warp/ffmpeg.sh 2>&1 | awk '{ print "ffmpeg: " $0 }' &
2525
sleep 1 #ensure this has started before moving on
2626

2727
#Generate selfsigned certs for warp
28-
source /certs/generate-certs.sh
28+
source /certs/generate-certs.sh 2>&1 | awk '{ print "generate-certs: " $0 }'
2929

3030
set -e
3131
#Start warp server
3232
/usr/bin/warp/warp &
33+
sleep 1 #ensure this has started before moving on
3334

3435
set -e
3536
#run child image entrypoint
36-
source /etc/warp/run-bash.sh
37+
echo "Running child scripts..."
38+
# Set the directory where the other bash files are located
39+
OTHER_SCRIPTS_DIR="/etc/warp/entrypoint.d"
40+
41+
# Check if the directory exists
42+
if [ -d "$OTHER_SCRIPTS_DIR" ]; then
43+
# Loop through all the files in the directory
44+
for script_file in $OTHER_SCRIPTS_DIR/*.sh; do
45+
# Check if the file is a bash script and is executable
46+
if [ -x "$script_file" ] && [ "${script_file: -3}" == ".sh" ]; then
47+
# Run the script
48+
echo "Running script $script_file"
49+
bash "$script_file"
50+
fi
51+
done
52+
else
53+
echo "Directory $OTHER_SCRIPTS_DIR not found "
54+
fi
3755

3856
wait -n
3957

docker/base/run-bash.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

docker/brave/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ FROM $WARP_IMAGE
1111
# Add Brave Browser repository and key
1212
RUN wget -qO - https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key add - ;\
1313
echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list; \
14-
sudo apt-get update && sudo apt-get install -y brave-browser; \
14+
sudo apt-get update && sudo apt-get install -y brave-browser dbus; \
1515
#
1616
# clean up
1717
#

docker/brave/brave.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ SCREEN_HEIGHT=1080
77

88
#Create brave user directory
99
USER_DATA_DIR="/home/$USER/.config/brave-browser"
10-
sudo mkdir -p "$USER_DATA_DIR"
10+
mkdir -p "$USER_DATA_DIR"
11+
sudo service dbus start
1112

1213
# Start Brave browser and play kygo
1314
brave-browser \

docker/nvidia/Dockerfile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,8 @@ RUN apt-get update; \
168168
#make directories for warp
169169
#
170170
mkdir -p /etc/warp /certs /media /usr/bin/warp /etc/warp/entrypoint.d;\
171-
chmod 1777 /certs; \
172-
chmod 1777 /media; \
173-
chmod 1777 /usr/bin/warp; \
174-
chmod 1777 /etc/warp/entrypoint.d; \
175-
chown ${USERNAME} /certs; \
176-
chown ${USERNAME} /usr/bin/warp; \
177-
chown ${USERNAME} /etc/warp/entrypoint.d; \
178-
chown ${USERNAME} /media; \
171+
chmod 1777 /certs /media /usr/bin/warp /etc/warp/entrypoint.d; \
172+
chown ${USERNAME} /certs /usr/bin/warp /etc/warp/entrypoint.d /media; \
179173
chown -R $USERNAME:$USERNAME /home/${USERNAME} ;\
180174
ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
181175

@@ -193,9 +187,6 @@ ENTRYPOINT [ "/usr/bin/tini","--" ]
193187
COPY docker/nvidia/entrypoint.sh /etc/warp/entrypoint.sh
194188
RUN chmod +x /etc/warp/entrypoint.sh
195189

196-
COPY docker/nvidia/run-bash.sh /etc/warp/run-bash.sh
197-
RUN chmod +x /etc/warp/run-bash.sh
198-
199190
COPY docker/nvidia/generate-certs.sh /certs/generate-certs.sh
200191
RUN chmod +x /certs/generate-certs.sh
201192

docker/nvidia/entrypoint.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
trap '[[ -n $(jobs -p) ]] && kill $(jobs -p); echo "Error: Warp failed with exit code $?" >&2; [[ -n $(jobs -p) ]] && wait $(jobs -p); exit $?' ERR
77

88
# Modify permissions of XDG_RUNTIME_DIR
9-
109
sudo -u $USER mkdir -pm700 /tmp/runtime-user
1110
sudo chown $USER:$USER /tmp/runtime-user
1211
sudo chmod 700 /tmp/runtime-user
@@ -27,6 +26,7 @@ export PATH="${PATH}:/usr/games:/opt/VirtualGL/bin"
2726
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"
2827

2928
# Run Xvfb server with required extensions
29+
echo "Starting Xvfb..."
3030
Xvfb "${DISPLAY}" -ac -screen "0" "8192x4096x24" -dpi "96" +extension "RANDR" +extension "GLX" +iglx +extension "MIT-SHM" +render -nolisten "tcp" -noreset -shmem &
3131
sleep 0.5
3232

@@ -42,19 +42,36 @@ pacmd set-default-sink vsink
4242
pacmd set-default-source vsink.monitor
4343

4444
#Start ffmpeg
45-
source /etc/warp/ffmpeg.sh &
45+
source /etc/warp/ffmpeg.sh 2>&1 | awk '{ print "ffmpeg: " $0 }' &
4646
sleep 1 #ensure this has started before moving on
4747

4848
#Generate selfsigned certs for warp
49-
source /certs/generate-certs.sh
49+
source /certs/generate-certs.sh 2>&1 | awk '{ print "generate-certs: " $0 }'
5050

5151
set -e
5252
#Start warp server
5353
/usr/bin/warp/warp &
54+
sleep 1 #ensure this has started before moving on
5455

5556
set -e
5657
#run child image entrypoint
57-
source /etc/warp/run-bash.sh
58+
echo "Running child scripts..."
59+
# Set the directory where the other bash files are located
60+
OTHER_SCRIPTS_DIR="/etc/warp/entrypoint.d"
61+
62+
# Check if the directory exists
63+
if [ -d "$OTHER_SCRIPTS_DIR" ]; then
64+
# Loop through all the files in the directory
65+
for script_file in $OTHER_SCRIPTS_DIR/*.sh; do
66+
# Check if the file is a bash script and is executable
67+
if [ -x "$script_file" ] && [ "${script_file: -3}" == ".sh" ]; then
68+
# Run the script
69+
bash "$script_file"
70+
fi
71+
done
72+
else
73+
echo "Directory $OTHER_SCRIPTS_DIR not found "
74+
fi
5875

5976
wait -n
6077

docker/nvidia/run-bash.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)