From 6d7dccb5292bab32b81024c31161a915d8274b5c Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Mon, 21 Apr 2025 02:54:37 +0800 Subject: [PATCH] clouddrive2: add clouddrive2 package --- net/clouddrive2/Makefile | 58 ++++++++++++++++++++++++ net/clouddrive2/files/clouddrive2.config | 4 ++ net/clouddrive2/files/clouddrive2.init | 41 +++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 net/clouddrive2/Makefile create mode 100644 net/clouddrive2/files/clouddrive2.config create mode 100644 net/clouddrive2/files/clouddrive2.init diff --git a/net/clouddrive2/Makefile b/net/clouddrive2/Makefile new file mode 100644 index 00000000..97cda4a9 --- /dev/null +++ b/net/clouddrive2/Makefile @@ -0,0 +1,58 @@ +# +# Copyright (C) 2017-2024 +# +# This is free software, licensed under the GNU General Public License v2. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=clouddrive2 +PKG_VERSION:=0.8.16 +PKG_RELEASE=1 + +ifeq ($(ARCH),aarch64) + PKG_ARCH:=aarch64 + PKG_HASH:=15c0b3fc370d3883a6f56136cee2f7580de691bc4ee7b782b47a43f4f8c31bde +else ifeq ($(ARCH),arm) + PKG_ARCH:=armv7 + PKG_HASH:=s305ed96ff66db8017e54988f44fe3d868ce0d28972a678eb4f16e3ab3d5a7aa4 +else ifeq ($(ARCH),x86_64) + PKG_ARCH:=x86_64 + PKG_HASH:=3545da7c7947fd3b085b8b130ce674d40c4d4a7435334c8c82da07065601cc05 +endif + +include $(INCLUDE_DIR)/package.mk + +define Package/clouddrive2 + SECTION:=net + CATEGORY:=Network + DEPENDS:=@(arm||aarch64||x86_64) +fuse-utils + TITLE:=CloudDrive2 +endef + +define Package/clouddrive2/description + CloudDrive2 is a cloud storage mounting tool for OpenWrt. +endef + +PKG_SOURCE:=clouddrive-2-linux-$(PKG_ARCH)-$(PKG_VERSION).tgz +PKG_SOURCE_URL:=https://github.com/cloud-fs/cloud-fs.github.io/releases/download/v$(PKG_VERSION) + +define Build/Prepare + $(call Build/Prepare/Default) + tar -xzvf $(DL_DIR)/clouddrive-2-linux-$(PKG_ARCH)-$(PKG_VERSION).tgz -C $(PKG_BUILD_DIR)/ --strip-components=1 +endef + +define Build/Compile +endef + +define Package/clouddrive2/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/clouddrive2.init $(1)/etc/init.d/clouddrive2 + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/clouddrive2.config $(1)/etc/config/clouddrive2 + $(INSTALL_DIR) $(1)/usr/share/clouddrive2 + $(INSTALL_BIN) $(PKG_BUILD_DIR)/clouddrive-2-linux-$(PKG_ARCH)-$(PKG_VERSION)/clouddrive $(1)/usr/share/clouddrive2/ + cp -rf $(PKG_BUILD_DIR)/clouddrive-2-linux-$(PKG_ARCH)-$(PKG_VERSION)/wwwroot $(1)/usr/share/clouddrive2/ +endef + +$(eval $(call BuildPackage,clouddrive2)) diff --git a/net/clouddrive2/files/clouddrive2.config b/net/clouddrive2/files/clouddrive2.config new file mode 100644 index 00000000..2876863b --- /dev/null +++ b/net/clouddrive2/files/clouddrive2.config @@ -0,0 +1,4 @@ +config clouddrive2 'main' + option enabled '0' + option port '19798' + option mount_point '/mnt/clouddrive' \ No newline at end of file diff --git a/net/clouddrive2/files/clouddrive2.init b/net/clouddrive2/files/clouddrive2.init new file mode 100644 index 00000000..54bcdd5b --- /dev/null +++ b/net/clouddrive2/files/clouddrive2.init @@ -0,0 +1,41 @@ +#!/bin/sh /etc/rc.common + +START=99 +STOP=15 +USE_PROCD=1 + +SERVICE=clouddrive2 +PROGDIR=/usr/share/clouddrive2/clouddrive + +load_config() { + config_load 'clouddrive2' + config_get_bool enabled main enabled 1 + config_get port main port 19798 + config_get mount_point main mount_point '/mnt/clouddrive' +} + +service_triggers() { + procd_add_reload_trigger "clouddrive2" +} + +start_service() { + load_config + [ "$enabled" = "1" ] || return + + [ -d "$mount_point" ] || mkdir -p "$mount_point" + + procd_open_instance + procd_set_param command "$PROGDIR" + procd_append_param command -p "$port" + procd_append_param command -m "$mount_point" + procd_set_param respawn + procd_close_instance + echo "$SERVICE started on port $port, mounted at $mount_point" +} + +stop_service() { + load_config + echo "Stopping $SERVICE" + killall -q clouddrive + [ -d "$mount_point" ] && fusermount -u "$mount_point" +}