summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/SiteSpecific/JoeySites.hs
diff options
context:
space:
mode:
authorJoey Hess2018-08-20 17:03:09 -0400
committerJoey Hess2018-08-20 17:03:09 -0400
commit4be2ad75fc22080a11ac3a0988bfc8113345fcaa (patch)
tree7556844c54118b8a0f1639f5e845e5aafb15dbcf /src/Propellor/Property/SiteSpecific/JoeySites.hs
parent36ee54ed2feb8adf4d8a9b072617b512cb9a7bed (diff)
propellor spin
Diffstat (limited to 'src/Propellor/Property/SiteSpecific/JoeySites.hs')
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs
index e94aca00..909ff929 100644
--- a/src/Propellor/Property/SiteSpecific/JoeySites.hs
+++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs
@@ -16,6 +16,7 @@ import qualified Propellor.Property.Cron as Cron
import qualified Propellor.Property.Service as Service
import qualified Propellor.Property.User as User
import qualified Propellor.Property.Group as Group
+import qualified Propellor.Property.Sudo as Sudo
import qualified Propellor.Property.Borg as Borg
import qualified Propellor.Property.Apache as Apache
import qualified Propellor.Property.Postfix as Postfix
@@ -1232,7 +1233,7 @@ newtype USBHubPort = USBHubPort Int
--
-- The hub port is turned on and off automatically as needed, using
-- uhubctl.
-autoMountDrive :: Mount.Label -> USBHubPort -> Maybe FilePath -> Property Linux
+autoMountDrive :: Mount.Label -> USBHubPort -> Maybe FilePath -> Property DebianLike
autoMountDrive label (USBHubPort port) malias = propertyList desc $ props
& File.ownerGroup mountpoint (User "joey") (Group "joey")
& File.dirExists mountpoint
@@ -1283,6 +1284,9 @@ autoMountDrive label (USBHubPort port) malias = propertyList desc $ props
`onChange` Systemd.daemonReloaded
& Systemd.enabled automount
& Systemd.started automount
+ & Sudo.sudoersDFile ("automount-" ++ label)
+ [ "%joey ALL= NOPASSWD: " ++ sudocommands
+ ]
where
mountpoint = "/media/joey/" ++ label
desc = "auto mount " ++ mountpoint
@@ -1290,3 +1294,7 @@ autoMountDrive label (USBHubPort port) malias = propertyList desc $ props
automount = svcbase ++ ".automount"
mount = svcbase ++ ".mount"
svcbase = Systemd.escapePath mountpoint
+ sudocommands = intercalate " , " $ map (\c -> "/bin/systemctl " ++ c)
+ [ "stop " ++ mountpoint
+ , "start " ++ mountpoint
+ ]