From 9b50b1b57bbb3ff45c4b5fdd7f95b4669982565a Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Fri, 22 Dec 2023 17:18:04 +0400 Subject: [PATCH 1/7] Add simple-http-server package --- .../network/simple-http-server/package.mk | 34 +++++++++++++++++++ .../system.d/simple-http-server.service | 14 ++++++++ 2 files changed, 48 insertions(+) create mode 100644 packages/network/simple-http-server/package.mk create mode 100644 packages/network/simple-http-server/system.d/simple-http-server.service diff --git a/packages/network/simple-http-server/package.mk b/packages/network/simple-http-server/package.mk new file mode 100644 index 0000000000..40b4520254 --- /dev/null +++ b/packages/network/simple-http-server/package.mk @@ -0,0 +1,34 @@ +# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv) +# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) +# Copyright (C) 2023-present NeoTheFox (https://github.com/NeoTheFox) + +PKG_NAME="simple-http-server" +PKG_VERSION="0.6.7" +PKG_LICENSE="MIT" +PKG_SITE="https://github.com/TheWaWaR/simple-http-server" +PKG_URL_ARM="https://github.com/TheWaWaR/simple-http-server/releases/download/v${PKG_VERSION}/armv7-unknown-linux-musleabihf-simple-http-server" +PKG_URL_AARCH64="https://github.com/TheWaWaR/simple-http-server/releases/download/v${PKG_VERSION}/aarch64-unknown-linux-musl-simple-http-server" +PKG_URL_X86_64="https://github.com/TheWaWaR/simple-http-server/releases/download/v${PKG_VERSION}/x86_64-unknown-linux-musl-simple-http-server" +PKG_LONGDESC="Simple http server in Rust" +PKG_TOOLCHAIN="manual" + +unpack() { + case $ARCH in + x86_64) + PKG_URL=$PKG_URL_X86_64 + ;; + arm) + PKG_URL=$PKG_URL_ARM + ;; + aarch64) + PKG_URL=$PKG_URL_AARCH64 + ;; + esac + + curl -L $PKG_URL -o ${PKG_DIR}/simple-http-server +} + +makeinstall_target() { + mkdir -p ${INSTALL}/usr/bin + install -Dm755 ${PKG_DIR}/simple-http-server ${INSTALL}/usr/bin/ +} diff --git a/packages/network/simple-http-server/system.d/simple-http-server.service b/packages/network/simple-http-server/system.d/simple-http-server.service new file mode 100644 index 0000000000..deae0df68c --- /dev/null +++ b/packages/network/simple-http-server/system.d/simple-http-server.service @@ -0,0 +1,14 @@ +[Unit] +Description=simple-http-server +Wants=network-pre.target +After=network-pre.target + +[Service] +ExecStart=/usr/bin/simple-http-server -i -s -u /storage +Restart=always +KillMode=process +Restart=on-failure +RestartSec=10 + +[Install] +WantedBy=multi-user.target From c0a4fba65c6799fa78e6ca0aa7bf3b43877762df Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Fri, 22 Dec 2023 17:45:52 +0400 Subject: [PATCH 2/7] Add simple-http-server service file and set root pw automatically --- packages/network/simple-http-server/package.mk | 11 +++++++++-- .../system.d/simple-http-server.service | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/network/simple-http-server/package.mk b/packages/network/simple-http-server/package.mk index 40b4520254..634fdf4814 100644 --- a/packages/network/simple-http-server/package.mk +++ b/packages/network/simple-http-server/package.mk @@ -13,6 +13,7 @@ PKG_LONGDESC="Simple http server in Rust" PKG_TOOLCHAIN="manual" unpack() { + mkdir -p ${PKG_BUILD} case $ARCH in x86_64) PKG_URL=$PKG_URL_X86_64 @@ -23,12 +24,18 @@ unpack() { aarch64) PKG_URL=$PKG_URL_AARCH64 ;; + *) + echo "Unsupported architecture!" + ;; esac - curl -L $PKG_URL -o ${PKG_DIR}/simple-http-server + curl -L $PKG_URL -o ${PKG_BUILD}/simple-http-server } makeinstall_target() { mkdir -p ${INSTALL}/usr/bin - install -Dm755 ${PKG_DIR}/simple-http-server ${INSTALL}/usr/bin/ + mkdir -p ${INSTALL}/usr/lib/systemd/system + + install -Dm755 ${PKG_BUILD}/simple-http-server ${INSTALL}/usr/bin/ + install -Dm644 ${PKG_DIR}/system.d/simple-http-server.service ${INSTALL}/usr/lib/systemd/system/ } diff --git a/packages/network/simple-http-server/system.d/simple-http-server.service b/packages/network/simple-http-server/system.d/simple-http-server.service index deae0df68c..f942ebcaac 100644 --- a/packages/network/simple-http-server/system.d/simple-http-server.service +++ b/packages/network/simple-http-server/system.d/simple-http-server.service @@ -4,7 +4,7 @@ Wants=network-pre.target After=network-pre.target [Service] -ExecStart=/usr/bin/simple-http-server -i -s -u /storage +ExecStart=/usr/bin/simple-http-server -i -p 80 -a root:$(get_setting root.password) -s -u /storage Restart=always KillMode=process Restart=on-failure From 522c4b517fb672156127757eca1978c207b7f39e Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Fri, 22 Dec 2023 17:56:32 +0400 Subject: [PATCH 3/7] add an option to enable the Simple HTTP Server to all platforms --- config/show_config | 1 + distributions/JELOS/options | 3 +++ packages/virtual/network/package.mk | 4 ++++ projects/Amlogic/devices/S922X/options | 3 +++ projects/PC/devices/AMD64/options | 3 +++ projects/Rockchip/devices/RK3326/options | 3 +++ projects/Rockchip/devices/RK3399/options | 3 +++ projects/Rockchip/devices/RK3566-X55/options | 3 +++ projects/Rockchip/devices/RK3566/options | 3 +++ projects/Rockchip/devices/RK3588/options | 5 ++++- 10 files changed, 30 insertions(+), 1 deletion(-) diff --git a/config/show_config b/config/show_config index 34b3b30c73..566d7edd6c 100644 --- a/config/show_config +++ b/config/show_config @@ -105,6 +105,7 @@ show_config() { config_message="${config_message}\n - SAMBA mounting support:\t\t $SAMBA_SUPPORT" config_message="${config_message}\n - SAMBA server support:\t\t $SAMBA_SERVER" config_message="${config_message}\n - SFTP server support:\t\t\t $SFTP_SERVER" + config_message="${config_message}\n - HTTP server support:\t\t\t $SIMPLE_HTTP_SERVER" config_message="${config_message}\n - OpenVPN support:\t\t\t $OPENVPN_SUPPORT" config_message="${config_message}\n - WireGuard support:\t\t\t $WIREGUARD_SUPPORT" config_message="${config_message}\n - ZeroTier support:\t\t\t $ZEROTIER_SUPPORT" diff --git a/distributions/JELOS/options b/distributions/JELOS/options index ada9612605..1a8b20f998 100644 --- a/distributions/JELOS/options +++ b/distributions/JELOS/options @@ -77,6 +77,9 @@ # build and install SFTP Server (yes / no) SFTP_SERVER="yes" +# build and install Simple HTTP Server (yes / no) + SIMPLE_HTTP_SERVER="no" + # build and install OpenVPN support (yes / no) OPENVPN_SUPPORT="no" diff --git a/packages/virtual/network/package.mk b/packages/virtual/network/package.mk index 0d7ca0cf64..de77b99ef1 100644 --- a/packages/virtual/network/package.mk +++ b/packages/virtual/network/package.mk @@ -19,6 +19,10 @@ if [ "${SAMBA_SERVER}" = "yes" ] || [ "$SAMBA_SUPPORT" = "yes" ]; then PKG_DEPENDS_TARGET="${PKG_DEPENDS_TARGET} samba" fi +if [ "${SIMPLE_HTTP_SERVER}" = "yes" ]; then + PKG_DEPENDS_TARGET="${PKG_DEPENDS_TARGET} simple-http-server" +fi + if [ "${OPENVPN_SUPPORT}" = "yes" ]; then PKG_DEPENDS_TARGET="${PKG_DEPENDS_TARGET} openvpn" fi diff --git a/projects/Amlogic/devices/S922X/options b/projects/Amlogic/devices/S922X/options index 21793470ba..66a843bcbf 100644 --- a/projects/Amlogic/devices/S922X/options +++ b/projects/Amlogic/devices/S922X/options @@ -108,6 +108,9 @@ # build and install SFTP Server (yes / no) SFTP_SERVER="yes" + # build and install Simple HTTP Server (yes / no) + SIMPLE_HTTP_SERVER="yes" + # build and install OpenVPN support (yes / no) OPENVPN_SUPPORT="no" diff --git a/projects/PC/devices/AMD64/options b/projects/PC/devices/AMD64/options index 4f50349f34..fdf0f3ff22 100644 --- a/projects/PC/devices/AMD64/options +++ b/projects/PC/devices/AMD64/options @@ -92,6 +92,9 @@ # build and install SFTP Server (yes / no) SFTP_SERVER="yes" + # build and install Simple HTTP Server (yes / no) + SIMPLE_HTTP_SERVER="yes" + # build and install OpenVPN support (yes / no) OPENVPN_SUPPORT="no" diff --git a/projects/Rockchip/devices/RK3326/options b/projects/Rockchip/devices/RK3326/options index 005eb5fcb8..3b385933f7 100644 --- a/projects/Rockchip/devices/RK3326/options +++ b/projects/Rockchip/devices/RK3326/options @@ -118,6 +118,9 @@ # build and install SFTP Server (yes / no) SFTP_SERVER="yes" + # build and install Simple HTTP Server (yes / no) + SIMPLE_HTTP_SERVER="yes" + # build and install OpenVPN support (yes / no) OPENVPN_SUPPORT="no" diff --git a/projects/Rockchip/devices/RK3399/options b/projects/Rockchip/devices/RK3399/options index a0dfa6dbf0..417bb42535 100644 --- a/projects/Rockchip/devices/RK3399/options +++ b/projects/Rockchip/devices/RK3399/options @@ -118,6 +118,9 @@ # build and install SFTP Server (yes / no) SFTP_SERVER="yes" + # build and install Simple HTTP Server (yes / no) + SIMPLE_HTTP_SERVER="yes" + # build and install OpenVPN support (yes / no) OPENVPN_SUPPORT="no" diff --git a/projects/Rockchip/devices/RK3566-X55/options b/projects/Rockchip/devices/RK3566-X55/options index 5d0b81281b..6fa8d72614 100644 --- a/projects/Rockchip/devices/RK3566-X55/options +++ b/projects/Rockchip/devices/RK3566-X55/options @@ -109,6 +109,9 @@ # build and install SFTP Server (yes / no) SFTP_SERVER="yes" + # build and install Simple HTTP Server (yes / no) + SIMPLE_HTTP_SERVER="yes" + # build and install OpenVPN support (yes / no) OPENVPN_SUPPORT="no" diff --git a/projects/Rockchip/devices/RK3566/options b/projects/Rockchip/devices/RK3566/options index ff8acbc0c9..771deed4b9 100644 --- a/projects/Rockchip/devices/RK3566/options +++ b/projects/Rockchip/devices/RK3566/options @@ -109,6 +109,9 @@ # build and install SFTP Server (yes / no) SFTP_SERVER="yes" + # build and install Simple HTTP Server (yes / no) + SIMPLE_HTTP_SERVER="yes" + # build and install OpenVPN support (yes / no) OPENVPN_SUPPORT="no" diff --git a/projects/Rockchip/devices/RK3588/options b/projects/Rockchip/devices/RK3588/options index 58130a3519..74b6521dcd 100755 --- a/projects/Rockchip/devices/RK3588/options +++ b/projects/Rockchip/devices/RK3588/options @@ -1,4 +1,4 @@ -################################################################################ +/################################################################################ # setup device defaults ################################################################################ @@ -119,6 +119,9 @@ # build and install SFTP Server (yes / no) SFTP_SERVER="yes" + # build and install Simple HTTP Server (yes / no) + SIMPLE_HTTP_SERVER="yes" + # build and install OpenVPN support (yes / no) OPENVPN_SUPPORT="no" From ac51d546d15af6442bbaeaad2050690ab218cea4 Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Fri, 22 Dec 2023 22:46:42 +0400 Subject: [PATCH 4/7] updated the simple-http-server service to work with emulationstation --- .../simple-http-server/system.d/simple-http-server.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/network/simple-http-server/system.d/simple-http-server.service b/packages/network/simple-http-server/system.d/simple-http-server.service index f942ebcaac..f88fb527ae 100644 --- a/packages/network/simple-http-server/system.d/simple-http-server.service +++ b/packages/network/simple-http-server/system.d/simple-http-server.service @@ -4,7 +4,7 @@ Wants=network-pre.target After=network-pre.target [Service] -ExecStart=/usr/bin/simple-http-server -i -p 80 -a root:$(get_setting root.password) -s -u /storage +ExecStart=/usr/bin/bash -c "source /etc/profile.d/001-functions && /usr/bin/simple-http-server -i -p 80 -a root:$(get_setting root.password) -s -u /storage" Restart=always KillMode=process Restart=on-failure From 816b99fa32a84e198bffcd9d1aefbf6bfd3616de Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Sat, 23 Dec 2023 00:10:49 +0400 Subject: [PATCH 5/7] fix a minor typo --- projects/Rockchip/devices/RK3588/options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/Rockchip/devices/RK3588/options b/projects/Rockchip/devices/RK3588/options index 74b6521dcd..12422c2a14 100755 --- a/projects/Rockchip/devices/RK3588/options +++ b/projects/Rockchip/devices/RK3588/options @@ -1,4 +1,4 @@ -/################################################################################ +################################################################################ # setup device defaults ################################################################################ From 673f5729209c9cea7ad36b0da561690bc2924678 Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Sat, 23 Dec 2023 00:24:38 +0400 Subject: [PATCH 6/7] remove unnecessary copyright --- packages/network/simple-http-server/package.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/network/simple-http-server/package.mk b/packages/network/simple-http-server/package.mk index 634fdf4814..8ecf9e1d7f 100644 --- a/packages/network/simple-http-server/package.mk +++ b/packages/network/simple-http-server/package.mk @@ -1,4 +1,3 @@ -# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv) # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) # Copyright (C) 2023-present NeoTheFox (https://github.com/NeoTheFox) From 0fb362fc99e3936dcc8f2b83405f3d045ee6c5f2 Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Sat, 23 Dec 2023 01:12:36 +0400 Subject: [PATCH 7/7] packaging refactoring --- .../network/simple-http-server/package.mk | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/packages/network/simple-http-server/package.mk b/packages/network/simple-http-server/package.mk index 8ecf9e1d7f..0dd47c7c2c 100644 --- a/packages/network/simple-http-server/package.mk +++ b/packages/network/simple-http-server/package.mk @@ -5,36 +5,31 @@ PKG_NAME="simple-http-server" PKG_VERSION="0.6.7" PKG_LICENSE="MIT" PKG_SITE="https://github.com/TheWaWaR/simple-http-server" -PKG_URL_ARM="https://github.com/TheWaWaR/simple-http-server/releases/download/v${PKG_VERSION}/armv7-unknown-linux-musleabihf-simple-http-server" -PKG_URL_AARCH64="https://github.com/TheWaWaR/simple-http-server/releases/download/v${PKG_VERSION}/aarch64-unknown-linux-musl-simple-http-server" -PKG_URL_X86_64="https://github.com/TheWaWaR/simple-http-server/releases/download/v${PKG_VERSION}/x86_64-unknown-linux-musl-simple-http-server" +PKG_DEPENDS_TARGET="toolchain" PKG_LONGDESC="Simple http server in Rust" PKG_TOOLCHAIN="manual" -unpack() { - mkdir -p ${PKG_BUILD} - case $ARCH in - x86_64) - PKG_URL=$PKG_URL_X86_64 - ;; - arm) - PKG_URL=$PKG_URL_ARM - ;; - aarch64) - PKG_URL=$PKG_URL_AARCH64 - ;; - *) - echo "Unsupported architecture!" - ;; - esac +case ${ARCH} in + x86_64) + PKG_URL="${PKG_SITE}/releases/download/v${PKG_VERSION}/x86_64-unknown-linux-musl-simple-http-server" + ;; + arm) + PKG_URL="${PKG_SITE}/releases/download/v${PKG_VERSION}/armv7-unknown-linux-musleabihf-simple-http-server" + ;; + aarch64) + PKG_URL="${PKG_SITE}/releases/download/v${PKG_VERSION}/aarch64-unknown-linux-musl-simple-http-server" + ;; +esac - curl -L $PKG_URL -o ${PKG_BUILD}/simple-http-server +unpack() { + mkdir -p ${PKG_BUILD} + cp ${SOURCES}/${PKG_NAME}/${PKG_NAME}-${PKG_VERSION}.${ARCH}*${PKG_NAME} ${PKG_BUILD}/simple-http-server } makeinstall_target() { - mkdir -p ${INSTALL}/usr/bin - mkdir -p ${INSTALL}/usr/lib/systemd/system + mkdir -p ${INSTALL}/usr/bin + install -Dm755 ${PKG_BUILD}/simple-http-server ${INSTALL}/usr/bin - install -Dm755 ${PKG_BUILD}/simple-http-server ${INSTALL}/usr/bin/ - install -Dm644 ${PKG_DIR}/system.d/simple-http-server.service ${INSTALL}/usr/lib/systemd/system/ + mkdir -p ${INSTALL}/usr/lib/systemd/system + install -Dm644 ${PKG_DIR}/system.d/simple-http-server.service ${INSTALL}/usr/lib/systemd/system }