summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authordameck2020-12-15 13:16:36 +0800
committerdameck2020-12-15 13:16:36 +0800
commit3fac92a88f6b5935752b820d5e2bac9c683bf391 (patch)
tree68501c8c20bda75fb1974f8eedd707cd7aa9bc49
downloadaur-3fac92a88f6b5935752b820d5e2bac9c683bf391.tar.gz
init commit
-rw-r--r--.SRCINFO19
-rw-r--r--10-rclone18
-rw-r--r--PKGBUILD27
-rwxr-xr-xrc5-mount-remote-google.sh103
-rw-r--r--rclone-mount-rc-local.service23
-rwxr-xr-xrclone-mount-rc.local8
6 files changed, 198 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..ace1a8604a90
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,19 @@
+pkgbase = networkmanager-dispatcher-rclone
+ pkgdesc = Dispatcher Script for rclone
+ pkgver = 1.0
+ pkgrel = 6
+ url = http://www.gnome.org/projects/NetworkManager/
+ arch = any
+ depends = networkmanager
+ depends = rclone
+ source = 10-rclone
+ source = rclone-mount-rc.local
+ source = rc5-mount-remote-google.sh
+ source = rclone-mount-rc-local.service
+ md5sums = 0418ba88270c4452031fb59121bd2398
+ md5sums = b2401ae52edc762f118e60fe052ee4b9
+ md5sums = 9ad06564d576cc625ee34486fd0903d3
+ md5sums = b7ca0d8313d0890663dff85693eab760
+
+pkgname = networkmanager-dispatcher-rclone
+
diff --git a/10-rclone b/10-rclone
new file mode 100644
index 000000000000..4b24e46a5257
--- /dev/null
+++ b/10-rclone
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+
+if [ -e /sys/fs/cgroup/systemd ]; then
+ case "$2" in
+ up)
+ systemctl start rclone-mount-rc-local.service
+ ;;
+ down)
+ systemctl stop rclone-mount-rc-local.service
+ ;;
+ esac
+else
+
+ if [ -e "/etc/rclone-mount-rc.local.d/rc5-mount-remote-google.sh" ]; then
+ /etc/rclone-mount-rc.local.d/rc5-mount-remote-google.sh
+ fi
+fi
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..38876f6ce2b7
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,27 @@
+# Maintainer:dmeck<dmeck@qq.com>
+pkgname=networkmanager-dispatcher-rclone
+pkgver=1.0
+pkgrel=6
+pkgdesc="Dispatcher Script for rclone"
+arch=(any)
+#license=('MIT')
+url="http://www.gnome.org/projects/NetworkManager/"
+depends=('networkmanager' 'rclone')
+source=("10-rclone"
+ "rclone-mount-rc.local"
+ "rc5-mount-remote-google.sh"
+ "rclone-mount-rc-local.service"
+ )
+md5sums=('0418ba88270c4452031fb59121bd2398'
+ 'b2401ae52edc762f118e60fe052ee4b9'
+ '9ad06564d576cc625ee34486fd0903d3'
+ 'b7ca0d8313d0890663dff85693eab760'
+)
+
+package() {
+ install -Dm700 $srcdir/rclone-mount-rc.local $pkgdir/etc/rclone-mount-rc.local
+ install -Dm700 $srcdir/rc5-mount-remote-google.sh $pkgdir/etc/rclone-mount-rc.local.d/rc5-mount-remote-google.sh
+ install -Dm700 $srcdir/rclone-mount-rc-local.service $pkgdir/usr/lib/systemd/system/rclone-mount-rc-local.service
+ install -Dm700 $srcdir/10-rclone $pkgdir/etc/NetworkManager/dispatcher.d/10-rclone
+}
+
diff --git a/rc5-mount-remote-google.sh b/rc5-mount-remote-google.sh
new file mode 100755
index 000000000000..f7687e326fe9
--- /dev/null
+++ b/rc5-mount-remote-google.sh
@@ -0,0 +1,103 @@
+#!/bin/bash
+set -u
+set -e
+
+
+
+
+
+target_base="/media/target"
+
+
+user_target_link_count=0
+user_target_bind_count=0
+user_target_bind_mount_count=0
+user_target_mount_count=0
+user_target_chown_count=0
+user_target_bind=("home/dmeck/work/google")
+
+
+# proxy list
+proxy_off(){
+ unset http_proxy
+ unset https_proxy
+ unset socks5_proxy
+ echo -e "已关闭代理"
+}
+proxy_on() {
+ export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
+ export http_proxy=http://127.0.0.1:8119
+ export https_proxy=$http_proxy
+ export socks5_proxy="127.0.0.1:1081"
+ echo -e "已开启代理"
+}
+
+rollback() {
+echo "umount user context"
+ proxy_off
+ sudo -u dmeck DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "disenable google rclone"
+ umount "/home/dmeck/work/google"
+exit
+}
+
+
+trap rollback INT TERM EXIT
+
+
+# unit bind target exist dirs
+echo "check bind target exist dirs"
+
+for item in "${user_target_bind[@]}";
+do
+ if ! test -d "$target_base/${item}"
+ then
+ mkdir -p "$target_base/${item}"
+ user_target_bind_count=`expr ${user_target_bind_count} + 1`
+
+ fi
+done
+echo "check bind target not exist by of create $user_target_bind_count dirs"
+
+#check target dirs is mount bind
+echo "check target dirs is mount bind"
+for item in "${user_target_bind[@]}";
+do
+ if grep -qs "$target_base/${item}" /proc/mounts ;
+ then
+ user_target_bind_mount_count=`expr ${user_target_bind_mount_count} + 1`
+ fi
+done
+echo "check target dirs is mount bind of $user_target_bind_mount_count"
+#bind target user context
+if [ $user_target_bind_mount_count -gt 0 ]
+then
+
+ echo "exist ${user_target_bind_mount_count} bind dir of target,exit!"
+ exit 1
+else
+ #run load mounts target
+ for item in "${user_target_bind[@]}";
+ do
+ if test -d "$target_base/${item}"
+ then
+ echo "$target_base/${item}"
+ sudo -u dmeck DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "enable google rclone "
+ if [ `whoami` == "root" ];then
+ sudo -H -E -u dmeck bash -c "$(declare -f proxy_on); proxy_on && nohup rclone mount google: \"$target_base/${item}\" --allow-other --allow-non-empty --vfs-cache-mode writes &"
+ else
+ proxy_on && nohup rclone mount google: "$target_base/${item}" --allow-other --allow-non-empty --vfs-cache-mode writes &
+ fi
+
+ user_target_mount_count=`expr ${user_target_mount_count} + 1`
+
+ fi
+ done
+ echo "target dirs is mount bind of $user_target_mount_count"
+
+
+
+fi
+
+
+
+trap - INT TERM EXIT
diff --git a/rclone-mount-rc-local.service b/rclone-mount-rc-local.service
new file mode 100644
index 000000000000..6f6740a8b252
--- /dev/null
+++ b/rclone-mount-rc-local.service
@@ -0,0 +1,23 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+# This unit gets pulled automatically into multi-user.target by
+# systemd-rc-local-generator if /etc/rc.local is executable.
+[Unit]
+Description=/etc/rclone-mount-rc.local Compatibility
+ConditionFileIsExecutable=/etc/rclone-mount-rc.local
+After=network.target
+
+[Service]
+Type=forking
+ExecStart=/etc/rclone-mount-rc.local start
+TimeoutSec=0
+RemainAfterExit=yes
+GuessMainPID=no
+
+[Install]
+WantedBy=multi-user.target
diff --git a/rclone-mount-rc.local b/rclone-mount-rc.local
new file mode 100755
index 000000000000..106065de923f
--- /dev/null
+++ b/rclone-mount-rc.local
@@ -0,0 +1,8 @@
+#!/bin/sh
+# /etc/rclone-mount-rc.local.d
+if test -d /etc/rclone-mount-rc.local.d; then
+ for rcscript in /etc/rclone-mount-rc.local.d/*.sh; do
+ test -r "${rcscript}" && sh ${rcscript}
+ done
+ unset rcscript
+fi