জিনোম-কিরিং-ডেমন পরে বশ স্ক্রিপ্ট শুরু করছেন তবে জিনোম-এনএফএসের আগে?


0

আমি উপলব্ধ হয়ে ওঠার sshfsপরে একটি মাউন্ট করা দরকার gnome-keyring-daemon(যেমন আমার। প্রোফাইলে নয় এবং সম্ভবত /etc/xdg/autostart/gnome-keyring-ssh.desktopএটি সম্পন্ন হওয়ার পরেও (তবে এর অনুমতিগুলি হ'ল - আর-আর -আর -) হওয়ায় আমার এতে সন্দেহ আছে), তবে gnome-encfsঅটোস্টার্টগুলির আগে ~/.config/autostart/gnome-encfs.desktop) ( ) আমার encfsউত্স ফোল্ডারগুলি sshfsমাউন্ট হিসাবে।

সুতরাং আমি আশ্চর্য হয়েছি কোন স্ক্রিপ্টটি লিখতে হবে, কোথায় এবং কীভাবে নির্ভরতাগুলি পরিচালনা করতে হবে - যেমন মাউন্টিংয়ের আগে কীরিং ড্যামনের প্রস্তুতি sshfs, তারপরে শুরু হওয়ার আগে সম্পূর্ণ মাউন্ট encfs।

আমার অনুসন্ধান এখনও পর্যন্ত ফলদায়ক হিসাবে প্রশংসিত যে কোনও এবং সমস্ত সহায়তা।

আমি উবুন্টু 10.04 এ আছি।


libertyzero.com/GEncfsM একটি সম্ভাব্য উত্তর বলে মনে হচ্ছে, তবে এর চেয়েও সহজ বিকল্প আছে কিনা তা নিয়ে আমি অবাক।
— asoundmove

autostartবর্ণগুলি অনুসারে এন্ট্রিগুলি কার্যকর করা হয়েছে, আপনি মূল এন্ট্রিগুলি পুনরায় অর্ডার না করলে আপনি কেবল এটি করতে পারবেন না।
— জাকুজে

হ্যাঁ, আমি একরকম সিদ্ধান্তে পৌঁছেছি। আমি উভয় পক্ষের প্রারম্ভিক স্ক্রিপ্টগুলিতে কীভাবে আটকানো যায় তা জানার চেষ্টা করছি, তবে কীভাবে তা নিশ্চিত আমি তা নিশ্চিত নই।
— asoundmove

উত্তর:


0

এর চেয়ে ভাল সমাধান না পেয়ে আমি প্রাক-কমান্ড বিকল্প যুক্ত করতে জিনোম-এনএফএস সংশোধন করার সিদ্ধান্ত নিয়েছি:

--- original gnome-encfs
+++ modified gnome-encfs
@@ -48,6 +48,7 @@
     econfig = None
     mpoint = None
     amount = None
+    precmd = None
# =============================================================================
# constants
@@ -125,6 +126,8 @@
                   help="Input for mount point edit")
     og.add_option("", "--amount", default=None,
                   help="Input for auto mount question")
+    og.add_option("", "--precmd", default=None,
+                  help="Input for pre-command question")
     og.add_option("", "--econfig", default=None,
                   help="Input for encfs config file question")
@@ -150,12 +153,12 @@
     opts.p2 = args and args.pop(0) or None

     if opts.add and not (opts.p1 and opts.p2):
-        op.error("add needs an EncFS path and a moint point")
+        op.error("add needs an EncFS path and a mount point")
         op.print_help()
         op.exit(1)

     if opts.remove and not opts.p1:
-        op.error("remove needs a moint point")
+        op.error("remove needs a mount point")
         op.print_help()
         op.exit(1)
@@ -164,6 +167,7 @@
     preset.epath = opts.epath
     preset.mpoint = opts.mpoint
     preset.amount = opts.amount
+    preset.precmd = opts.precmd
     preset.econfig = opts.econfig

     return opts
@@ -220,7 +224,7 @@    _items_cached = None  
-def _get_items(mpoint=None, epath=None, anypath=None, amount=None):
+def _get_items(mpoint=None, epath=None, anypath=None, amount=None, precmd=None):
     """Get all EncFS items or those matching given attributes."""

     global _items_cached
@@ -243,6 +247,8 @@
             continue
         if amount and item.attributes["auto-mount"] != amount:
             continue
+        if precmd and item.attributes["pre-command"] != precmd:
+            continue
         match.append(item)

     return match
@@ -292,10 +298,12 @@
         epath = item.attributes["encfs-path"]
         mpoint = item.attributes["mount-point"]
         amount = item.attributes["auto-mount"]
+        precmd = item.attributes["pre-command"]
         econfig = item.attributes.get("encfs-config", "-")
         print("* encfs path     : %s" % epath)
         print("  mount point    : %s" % mpoint)
         print("  mount at login : %s" % (amount == "y" and "yes" or "no"))
+        print("  pre command    : %s" % precmd)
         print("  encfs config   : %s" % econfig)

     return RC_OK
@@ -316,8 +324,9 @@
     secret = preset.password or getpass.getpass("EncFS password: ")
     amount = preset.amount or raw_input("Mount at login [Y/n]: ") or "y"
     amount = amount.strip()[0].lower() == "y" and "y" or "n"
+    precmd = preset.precmd or raw_input("Pre command: ") or None
     attr = {"encfs-path": epath, "mount-point": mpoint, "auto-mount": amount,
-        "encfs-config": econfig}
+        "pre-command": precmd, "encfs-config": econfig}
     attr.update(GENCFS_ATTR)
     name = "EncFS mount at %s" % mpoint
     gk.item_create_sync(KEYRING, ITYPE, name, attr, secret, False)
@@ -343,6 +352,7 @@
         epath = item.attributes["encfs-path"]
         mpoint = item.attributes["mount-point"]
         amount = item.attributes["auto-mount"]
+        precmd = item.attributes["pre-command"]
         econfig = item.attributes.get("encfs-config", "-")
         epath = preset.epath or raw_input("EncFS path [%s]: " % epath) or epath
         econfig = preset.econfig or raw_input("EncFS config file [%s] (`-`: default): " % econfig) or econfig
@@ -351,6 +361,7 @@
         hint = amount == "y" and "Y/n" or "y/N"
         amount = preset.amount or raw_input("Mount at login [%s]: " % hint) or amount
         amount = amount.strip()[0].lower() == "y" and "y" or "n"
+        precmd = preset.precmd or raw_input("Pre command: ") or None
         mpoint = _pathify(mpoint)
         epath = _pathify(epath)
@@ -368,6 +379,7 @@
         attributes["encfs-path"] = epath
         attributes["mount-point"] = mpoint
         attributes["auto-mount"] = amount
+        attributes["pre-command"] = precmd
         attributes["encfs-config"] = econfig
         gk.item_set_attributes_sync(KEYRING, item.item_id, attributes)
         info = gk.item_get_info_sync(KEYRING, item.item_id)
@@ -427,6 +440,18 @@
             msg += "mount point does not exist or is not a directory"
             rc |= RC_INVALID_PATH
         else:
+            if precmd != None:
+                # fire command and forget (do all the error handling in
+                # pre-command - no tie in here if it fails)
+                # My use case: mount sshfs before encfs, if the sshfs
+                # mount fails, then encfs will start on an empty
+                # directory.
+                cmd = precmd.split()
+       #print("pre command    : %s" % precmd)
+       #print("pre command    : %s" % cmd)
+                p = subprocess.Popen(cmd)
+                p.wait()
+                print("Pre command return code: %s" % p.returncode)
             cmd = ["encfs", "-o", "nonempty", "-S", epath, mpoint]
             p = subprocess.Popen(cmd, stdin=subprocess.PIPE,
                 env=_encfs_env(econfig))
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.