summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/SiteSpecific
diff options
context:
space:
mode:
authorJoey Hess2018-08-26 10:44:25 -0400
committerJoey Hess2018-08-26 10:44:25 -0400
commite4ce2792bbd7ab7495ea86fd4228ad3595d8b48a (patch)
tree51d2083f9456cc86c28976d0dd069faaf0531d03 /src/Propellor/Property/SiteSpecific
parentd595fdfa25eab311d2407f86efbb85f6d52c5603 (diff)
parent2a499012b680db73df20b6b5b0bc4959ab65006d (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/SiteSpecific')
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs
index 2425ddb9..fa7cb064 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
@@ -1214,9 +1215,14 @@ cubieTruckOneWire =
-- My home networked attached storage server.
homeNAS :: Property DebianLike
homeNAS = propertyList "home NAS" $ props
- & autoMountDrive "archive-10" (USBHubPort 1) (Just "archive")
+ & Apt.installed ["uhubctl"]
+ & "/etc/udev/rules.d/52-startech-hub.rules" `File.hasContent`
+ [ "# let users power control startech hub with uhubctl"
+ , "ATTR{idVendor}==\"0409\", ATTR{idProduct}==\"005a\", MODE=\"0666\""
+ ]
+ & autoMountDrive "archive-10" (USBHubPort 1) (Just "archive-older")
& autoMountDrive "archive-11" (USBHubPort 2) (Just "archive-old")
- & autoMountDrive "archive-12" (USBHubPort 3) (Just "archive-older")
+ & autoMountDrive "archive-12" (USBHubPort 3) (Just "archive")
& autoMountDrive "passport" (USBHubPort 4) Nothing
& Apt.installed ["git-annex", "borgbackup"]
@@ -1229,7 +1235,6 @@ newtype USBHubPort = USBHubPort Int
-- uhubctl.
autoMountDrive :: Mount.Label -> USBHubPort -> Maybe FilePath -> Property DebianLike
autoMountDrive label (USBHubPort port) malias = propertyList desc $ props
- & Apt.installed ["uhubctl"]
& File.ownerGroup mountpoint (User "joey") (Group "joey")
& File.dirExists mountpoint
& case malias of
@@ -1238,11 +1243,13 @@ autoMountDrive label (USBHubPort port) malias = propertyList desc $ props
Nothing -> doNothing <!> doNothing
& File.hasContent ("/etc/systemd/system/" ++ mount)
[ "[Unit]"
- , "Description=Mount " ++ label
+ , "Description=" ++ label
, "Requires=" ++ hub
, "After=" ++ hub
, "[Mount]"
- , "Type=auto"
+ -- avoid mounting whenever the block device is available,
+ -- only want to automount on deman
+ , "Options=noauto"
, "What=/dev/disk/by-label/" ++ label
, "Where=" ++ mountpoint
, "[Install]"
@@ -1277,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
@@ -1284,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
+ ]