This commit is contained in:
		
							
								
								
									
										18
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -1,5 +1,7 @@
 | 
			
		||||
# FROM alpine:latest
 | 
			
		||||
FROM alpine:3.9
 | 
			
		||||
FROM alpine:latest
 | 
			
		||||
 | 
			
		||||
ARG S6_OVERLAY_VERSION=3.1.0.1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
LABEL org.opencontainers.image.source="https://git.sthope.dev/sthope/DockerContainer-randomPwd"
 | 
			
		||||
LABEL Maintainer="Sthope"
 | 
			
		||||
@@ -14,7 +16,13 @@ RUN set -xe \
 | 
			
		||||
    && adduser -u ${PUID} -G mosquitto -h /mosquitto/ -D mosquitto \
 | 
			
		||||
    && apk add --no-cache --purge -uU mosquitto mosquitto-libs mosquitto-clients 
 | 
			
		||||
 | 
			
		||||
WORKDIR /workspace
 | 
			
		||||
COPY root/defaults/temp2mqtt /workspace
 | 
			
		||||
WORKDIR /config
 | 
			
		||||
# COPY root/defaults/temp2mqtt /config
 | 
			
		||||
 | 
			
		||||
CMD [ "sh", "./temp2mqtt" ]
 | 
			
		||||
# CMD [ "sh", "./temp2mqtt" ]
 | 
			
		||||
 | 
			
		||||
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
 | 
			
		||||
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
 | 
			
		||||
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
 | 
			
		||||
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
 | 
			
		||||
ENTRYPOINT ["/init"]
 | 
			
		||||
@@ -7,8 +7,8 @@ PROXMOX_NAME="${PROXMOX_NAME:-pve}";
 | 
			
		||||
 | 
			
		||||
TEMP=$(clear;sensors | sed -n 9p | sed 's/^[^=:]*[=:]//' | sed -r 's/\s+//g');
 | 
			
		||||
 | 
			
		||||
[[ ! -f /mosquitto/config/temp2mqtt ]] && touch /mosquitto/config/temp2mqtt;
 | 
			
		||||
cat <<EOF >> /mosquitto/config/temp2mqtt
 | 
			
		||||
[[ ! -f /config/temp2mqtt ]] && touch /config/temp2mqtt;
 | 
			
		||||
cat <<EOF >> /config/temp2mqtt
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
#  ___  _    _          _ __      
 | 
			
		||||
# / __|| |_ | |_   ___ | '_ \ ___ 
 | 
			
		||||
@@ -25,5 +25,5 @@ TEMP=$(clear;sensors | sed -n 9p | sed 's/^[^=:]*[=:]//' | sed -r 's/\s+//g');
 | 
			
		||||
mosquitto_pub -h "${MQTT_BROKER}" -u "${USERNAME}" -P "${PASSWORD}" -t proxmox/"${PROXMOX_NAME}"/cpu_temp -m "${TEMP}"
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
chown -R mosquitto:mosquitto /mosquitto/;
 | 
			
		||||
chmod +x /mosquitto/config/temp2mqtt;
 | 
			
		||||
chown -R mosquitto:mosquitto /config/temp2mqtt;
 | 
			
		||||
chmod +x /config/temp2mqtt;
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
#!/usr/bin/with-contenv bash
 | 
			
		||||
 | 
			
		||||
cd /mosquitto/config || exit 1;
 | 
			
		||||
cd /config/ || exit 1;
 | 
			
		||||
 | 
			
		||||
while /mosquitto/config/temp2mqtt; do sleep 10; done
 | 
			
		||||
while /config/temp2mqtt; do sleep 10; done
 | 
			
		||||
		Reference in New Issue
	
	Block a user