Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 55c9da9

Browse files
authored
Merge pull request #6 from linuxserver/master-autorun
add ability to autostart applications using websocat
2 parents 9972f2a + 1fc91d1 commit 55c9da9

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ RUN \
132132
xterm && \
133133
apt-get install -qy --no-install-recommends \
134134
$(cat /tmp/out/DEPENDENCIES) && \
135-
cd /usr/bin && \
135+
echo "**** grab websocat ****" && \
136+
WEBSOCAT_RELEASE=$(curl -sX GET "https://api.github.com/repos/vi/websocat/releases/latest" \
137+
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
138+
curl -o \
139+
/usr/bin/websocat -L \
140+
"https://github.com/vi/websocat/releases/download/${WEBSOCAT_RELEASE}/websocat_nossl_amd64-linux-static" && \
141+
chmod +x /usr/bin/websocat && \
136142
echo "**** cleanup ****" && \
137143
apt-get autoclean && \
138144
rm -rf \

Dockerfile.aarch64

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ RUN \
132132
xterm && \
133133
apt-get install -qy --no-install-recommends \
134134
$(cat /tmp/out/DEPENDENCIES) && \
135-
cd /usr/bin && \
135+
echo "**** grab websocat ****" && \
136+
WEBSOCAT_RELEASE=$(curl -sX GET "https://api.github.com/repos/vi/websocat/releases/latest" \
137+
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
138+
curl -o \
139+
/usr/bin/websocat -L \
140+
"https://github.com/vi/websocat/releases/download/${WEBSOCAT_RELEASE}/websocat_nossl_arm-linux-static" && \
141+
chmod +x /usr/bin/websocat && \
136142
echo "**** cleanup ****" && \
137143
apt-get autoclean && \
138144
rm -rf \

Dockerfile.armhf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ RUN \
133133
apt-get install -qy --no-install-recommends \
134134
$(cat /tmp/out/DEPENDENCIES) && \
135135
cd /usr/bin && \
136+
echo "**** grab websocat ****" && \
137+
WEBSOCAT_RELEASE=$(curl -sX GET "https://api.github.com/repos/vi/websocat/releases/latest" \
138+
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
139+
curl -o \
140+
/usr/bin/websocat -L \
141+
"https://github.com/vi/websocat/releases/download/${WEBSOCAT_RELEASE}/websocat_nossl_arm-linux-static" && \
142+
chmod +x /usr/bin/websocat && \
136143
echo "**** cleanup ****" && \
137144
apt-get autoclean && \
138145
rm -rf \

root/etc/services.d/autostart/run

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
# just sleep if autostart is not enabled
4+
if [ -z ${GUIAUTOSTART+x} ]; then
5+
echo "[guac-init] Auto start not set, application start on login"
6+
sleep infinity
7+
# start abc session by sending a token to guacamole via websockets
8+
else
9+
# make sure services are up
10+
until \
11+
$(true &>/dev/null </dev/tcp/127.0.0.1/3350) && \
12+
$(true &>/dev/null </dev/tcp/127.0.0.1/4822) && \
13+
$(true &>/dev/null </dev/tcp/127.0.0.1/${CUSTOM_PORT:=3000}) &&
14+
$(true &>/dev/null </dev/tcp/127.0.0.1/3389)
15+
do
16+
sleep .5
17+
done
18+
echo "[guac-init] Auto start set, starting application"
19+
sleep 1
20+
# generate a token based on env vars
21+
cd /gclient
22+
TOKEN=$(node maketoken.js)
23+
websocat -q -n ws://localhost:${CUSTOM_PORT:=3000}/guaclite?token=${TOKEN}
24+
sleep infinity
25+
fi

0 commit comments

Comments
 (0)