Opt: update install script and dockerfile

pull/40/head
zijiren233 1 year ago
parent 2dd309c6ce
commit 71d1b96e69

@ -6,28 +6,26 @@ WORKDIR /synctv
COPY ./ ./ COPY ./ ./
RUN apk add --no-cache bash curl gcc git go musl-dev RUN apk add --no-cache bash curl gcc git go musl-dev && \
bash script/build.sh -P -v ${VERSION}
RUN bash script/build.sh -P -v ${VERSION}
From alpine:latest From alpine:latest
ENV PUID=0 PGID=0 UMASK=022
COPY --from=builder /synctv/build/synctv /usr/local/bin/synctv COPY --from=builder /synctv/build/synctv /usr/local/bin/synctv
COPY script/entrypoint.sh /entrypoint.sh COPY script/entrypoint.sh /entrypoint.sh
RUN apk add --no-cache bash ca-certificates su-exec tzdata RUN apk add --no-cache bash ca-certificates su-exec tzdata && \
rm -rf /var/cache/apk/* && \
RUN chmod +x /entrypoint.sh chmod +x /entrypoint.sh && \
mkdir -p ~/.synctv
ENV PUID=0 PGID=0 UMASK=022
RUN mkdir -p ~/.synctv
WORKDIR ~/.synctv WORKDIR ~/.synctv
EXPOSE 8080/tcp 8080/udp EXPOSE 8080/tcp 8080/udp
VOLUME [ ~/.synctv ] VOLUME [ "~/.synctv" ]
CMD [ "/entrypoint.sh" ] CMD [ "/entrypoint.sh" ]

@ -12,6 +12,11 @@ function Help() {
} }
function Init() { function Init() {
# Check if the user is root or sudo
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
VERSION="latest" VERSION="latest"
InitOS InitOS
InitArch InitArch
@ -112,7 +117,7 @@ function InitDownloadTools() {
function Download() { function Download() {
case "$download_tool" in case "$download_tool" in
curl) curl)
curl -L "$1" -o "$2" curl -L "$1" -o "$2" --progress-bar
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "download $1 failed" echo "download $1 failed"
exit 1 exit 1
@ -178,6 +183,10 @@ function InstallWithVersion() {
} }
function InitLinuxSystemctlService() { function InitLinuxSystemctlService() {
if [ -z "$(command -v systemctl)" ]; then
echo "systemctl command not found"
exit 1
fi
mkdir -p "/opt/synctv" mkdir -p "/opt/synctv"
if [ ! -d "/etc/systemd/system" ]; then if [ ! -d "/etc/systemd/system" ]; then
echo "/etc/systemd/system not found" echo "/etc/systemd/system not found"
@ -214,14 +223,6 @@ function InitSystemctlService() {
linux) linux)
InitLinuxSystemctlService InitLinuxSystemctlService
;; ;;
darwin)
echo "darwin not support"
exit 1
;;
*)
echo "OS not supported"
exit 1
;;
esac esac
} }

Loading…
Cancel
Save