-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
145 lines (131 loc) · 13.2 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
FROM debian:buster-slim
LABEL maintainer "Chaojun Tan <https://github.com/tcjj3>"
ADD upstream-preview-custom-light-auth.original.tpl /opt/upstream-preview-custom-light-auth.original.tpl
ADD upstream-preview-custom-dark-auth.original.tpl /opt/upstream-preview-custom-dark-auth.original.tpl
ADD upstream-preview-custom-light.original.tpl /opt/upstream-preview-custom-light.original.tpl
ADD upstream-preview-custom-dark.original.tpl /opt/upstream-preview-custom-dark.original.tpl
ADD 404.original.htm /opt/404.original.htm
ADD 401.original.htm /opt/401.original.htm
ADD LatestImage.htm /opt/LatestImage.htm
ADD upstream-preview-light.tpl /opt/upstream-preview-light.tpl
ADD upstream-preview-dark.tpl /opt/upstream-preview-dark.tpl
ADD upstream-preview.tpl /opt/upstream-preview.tpl
ADD upstream.tpl /opt/upstream.tpl
ADD latest_image_links.sh /opt/latest_image_links.sh
ADD entrypoint.sh /opt/entrypoint.sh
RUN export DIR_TMP="$(mktemp -d)" \
&& sed -i "s/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g" /etc/apt/sources.list \
&& sed -i "s/security.debian.org/mirrors.tuna.tsinghua.edu.cn/g" /etc/apt/sources.list \
&& apt-get update \
|| echo "continue..." \
&& apt-get install --no-install-recommends -y cron \
ca-certificates \
curl \
wget \
unzip \
git \
python3 \
python3-pip \
nginx \
vim \
psmisc \
procps \
&& chmod +x /opt/*.sh \
&& mkdir -p /etc/caddy \
&& mkdir -p /opt/xrit-rx_config \
&& git clone https://github.com/sam210723/xrit-rx /usr/local/bin/xrit-rx \
&& mkdir -p /usr/local/bin/xrit-rx/src/received \
&& mkdir -p /usr/local/bin/xrit-rx/src/received/LRIT \
&& mkdir -p /usr/local/bin/xrit-rx/src/LatestImages \
&& cp -r /usr/local/bin/xrit-rx/src/html /usr/local/bin/xrit-rx/src/html_coloured \
&& cp /usr/local/bin/xrit-rx/src/html_coloured/js/dash.js /usr/local/bin/xrit-rx/src/html_coloured/js/dash.bak.js \
&& sed -i "s#if (ext != \"txt\") {#if (ext != \"txt\") {\n if (url.indexOf(\"/FD/\") > -1) {\n var fname_new = fname + \"-fc\";\n \n var url_old = url;\n var Regex_FullDisk = /received\\\/LRIT\\\//i;\n url = url.replace(Regex_FullDisk, \"received/LRIT/COLOURED/\");\n Regex_FullDisk = /.jpg/i;\n url = url.replace(Regex_FullDisk, \"-fc.jpg\");\n Regex_FullDisk = /\\\/FD\\\//i;\n url = url.replace(Regex_FullDisk, \"/\");\n }\n#gi" /usr/local/bin/xrit-rx/src/html_coloured/js/dash.js \
&& sed -i "s#if (img.getAttribute(\"src\") != url) {#if (img.getAttribute(\"src\") != url) {\n if (url_old != null \&\& url_old != \"\" \&\& url_old != url) {\n img.onerror = function() {img.setAttribute(\"src\", url_old); link.setAttribute(\"href\", url_old);};\n img.onload = function() {if (img.getAttribute(\"src\").indexOf(\"-fc\") > -1) cap.innerText = fname_new;};\n } else {\n img.onerror = function() {};\n img.onload = function() {};\n }\n#gi" /usr/local/bin/xrit-rx/src/html_coloured/js/dash.js \
&& cp /usr/local/bin/xrit-rx/src/html_coloured/js/dash.js /usr/local/bin/xrit-rx/src/html_coloured/js/dash_coloured.js \
&& cp /usr/local/bin/xrit-rx/src/html_coloured/index.html /usr/local/bin/xrit-rx/src/html_coloured/index.bak.html \
&& sed -i "s#\"js/dash.js\"#\"js/dash_coloured.js\"#gi" /usr/local/bin/xrit-rx/src/html_coloured/index.html \
&& pip3 install --no-cache-dir -r /usr/local/bin/xrit-rx/requirements.txt \
&& curl -L http://nmsc.kma.go.kr/resources/enhome/resources/satellites/coms/COMS_Decryption_Sample_Cpp.zip -o ${DIR_TMP}/COMS_Decryption_Sample_Cpp.zip \
&& unzip -j ${DIR_TMP}/COMS_Decryption_Sample_Cpp.zip EncryptionKeyMessage_001F2904C905.bin -d ${DIR_TMP} \
&& mv ${DIR_TMP}/EncryptionKeyMessage_001F2904C905.bin /usr/local/bin/xrit-rx/src/EncryptionKeyMessage_001F2904C905.bin \
&& python3 /usr/local/bin/xrit-rx/src/tools/keymsg-decrypt.py /usr/local/bin/xrit-rx/src/EncryptionKeyMessage_001F2904C905.bin 001F2904C905 \
&& cp /usr/local/bin/xrit-rx/src/xrit-rx.py /usr/local/bin/xrit-rx/src/xrit-rx.bak.py \
&& cp /usr/local/bin/xrit-rx/src/demuxer.py /usr/local/bin/xrit-rx/src/demuxer.bak.py \
&& cp /usr/local/bin/xrit-rx/src/ccsds.py /usr/local/bin/xrit-rx/src/ccsds.bak.py \
&& tmp=`grep "except OSError:" /usr/local/bin/xrit-rx/src/xrit-rx.py` || echo "continue..." \
&& [ -z "$tmp" ] && sed -Ei "s#except ConnectionResetError:#except OSError:\n print(Fore.WHITE + Back.RED + Style.BRIGHT + \"CONNECTION DOES NOT EXIST\")\n safe_stop()\n except ConnectionResetError:#gi" /usr/local/bin/xrit-rx/src/xrit-rx.py || echo "continue..." \
&& tmp=`grep "except Exception as e:" /usr/local/bin/xrit-rx/src/xrit-rx.py | awk 'END{print NR}'` || echo "continue..." \
&& [ $((tmp)) -lt 2 ] && sed -i ':a;N;$!ba; s#\(.*\)safe_stop()\(.*\)#\1safe_stop()\nexcept Exception as e:\n print(e)\n safe_stop()\2#gi' /usr/local/bin/xrit-rx/src/xrit-rx.py || echo "continue..." \
&& tmp=`grep "self.demuxer.lastImage = self.cProduct.last" /usr/local/bin/xrit-rx/src/demuxer.py | awk 'END{print NR}'` || echo "continue..." \
&& [ $((tmp)) -lt 2 ] && sed -i ':a;N;$!ba; s#\(.*\)self.cProduct = None\(.*\)#\1self.demuxer.lastImage = self.cProduct.last\n self.cProduct = None\2#gi' /usr/local/bin/xrit-rx/src/demuxer.py || echo "continue..." \
&& tmp=`grep "except ValueError:" /usr/local/bin/xrit-rx/src/ccsds.py` || echo "continue..." \
&& [ -z "$tmp" ] && (sed -Ei "s/self.PLAINTEXT = self.headerField \+ decData/#self.PLAINTEXT = self.headerField + decData/gi" /usr/local/bin/xrit-rx/src/ccsds.py && tmp=`grep "import colorama" /usr/local/bin/xrit-rx/src/ccsds.py` || echo "continue..." && ([ -z "$tmp" ] && sed -Ei "s#import os#import os\n\nimport colorama\nfrom colorama import Fore, Back, Style#gi" /usr/local/bin/xrit-rx/src/ccsds.py && sed -Ei "s#decData = decoder.decrypt\(self.dataField\)#try:\n decData = decoder.decrypt(self.dataField)\n self.PLAINTEXT = self.headerField + decData\n except ValueError:\n print(\" \" + Fore.WHITE + Back.RED + Style.BRIGHT + \"DES ECB DECRYPT ERROR: ValueError\")\n else:\n decData = None#gi" /usr/local/bin/xrit-rx/src/ccsds.py) || sed -Ei "s#decData = decoder.decrypt\(self.dataField\)#try:\n decData = decoder.decrypt(self.dataField)\n self.PLAINTEXT = self.headerField + decData\n except ValueError:\n print(\" \" + \"DES ECB DECRYPT ERROR: ValueError\")\n else:\n decData = None#gi" /usr/local/bin/xrit-rx/src/ccsds.py) || echo "continue..." \
&& pip3 install --no-cache-dir imageio \
&& mkdir -p /etc/nginx || echo "continue..." \
&& mkdir -p /etc/nginx/sites-available || echo "continue..." \
&& mkdir -p /etc/nginx/sites-enabled || echo "continue..." \
&& touch /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo "server {" > /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " listen 4041 default_server;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " listen [::]:4041 default_server;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " root /usr/local/bin/xrit-rx/src/html;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " index index.html index.htm;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " server_name _;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " location / {" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " try_files \$uri \$uri/ =404;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " }" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo "}" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo "" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo "server {" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " listen 4042 default_server;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " listen [::]:4042 default_server;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " root /usr/local/bin/xrit-rx/src/html_coloured;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " index index.html index.htm;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " server_name _;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " location / {" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " try_files \$uri \$uri/ =404;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " }" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo "}" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo "" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo "server {" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " listen 4043 default_server;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " listen [::]:4043 default_server;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " root /usr/local/bin/xrit-rx/src/LatestImages;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " index index.html index.htm LatestFullDisk-fc.htm LatestFullDisk.htm LatestImage.htm LatestMerged.htm LatestFullDisk-fc.jpg LatestFullDisk.jpg LatestImage.jpg LatestMerged.gif;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " server_name _;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " location / {" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " try_files \$uri \$uri/ =404;" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " }" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo " " >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& echo "}" >> /etc/nginx/sites-available/dashboard_staticfiles || echo "continue..." \
&& ln -s /etc/nginx/sites-available/dashboard_staticfiles /etc/nginx/sites-enabled/dashboard_staticfiles || echo "continue..." \
&& if [ "$(dpkg --print-architecture)" = "armhf" ]; then \
ARCH="arm7"; \
else \
ARCH=$(dpkg --print-architecture); \
fi \
&& mkdir -p ${DIR_TMP}/caddy \
&& curl -L -o ${DIR_TMP}/caddy/caddy.tar.gz https://github.com/caddyserver/caddy/releases/download/v1.0.4/caddy_v1.0.4_linux_${ARCH}.tar.gz \
&& tar -zxf ${DIR_TMP}/caddy/caddy.tar.gz -C ${DIR_TMP}/caddy \
&& mv ${DIR_TMP}/caddy/caddy /usr/local/bin/caddy \
&& curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash \
&& chmod +x /opt/* /usr/local/bin/xrit-rx/src/xrit-rx.py \
&& echo "* * * * * /opt/latest_image_links.sh &" > ${DIR_TMP}/crontab \
&& crontab ${DIR_TMP}/crontab \
&& rm -rf ${DIR_TMP} \
&& apt-get autoremove --purge unzip git -y
ENTRYPOINT ["sh", "-c", "/opt/entrypoint.sh"]