summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorJoey Hess2018-08-19 23:07:32 -0400
committerJoey Hess2018-08-19 23:07:32 -0400
commit796488188b922aa071e8d5dcbda054e70f1bdad2 (patch)
treee66f85b7faba03c2972053f7c49c723ad7963559 /src/Propellor
parent234413e6e73495b67c90e371c3f43ccb60dcbbf4 (diff)
propellor spin
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs
index f5514721..0ea6937e 100644
--- a/src/Propellor/Property/SiteSpecific/JoeySites.hs
+++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs
@@ -1214,10 +1214,10 @@ cubieTruckOneWire =
-- My home networked attached storage server.
homeNAS :: Property DebianLike
homeNAS = propertyList "home NAS" $ props
- & autoMountDrive "archive-10" (USBHubPort 1)
- & autoMountDrive "archive-11" (USBHubPort 2)
- & autoMountDrive "archive-12" (USBHubPort 3)
- & autoMountDrive "passport" (USBHubPort 4)
+ & autoMountDrive "archive-10" (USBHubPort 1) (Just "archive")
+ & autoMountDrive "archive-11" (USBHubPort 2) (Just "archive-old")
+ & autoMountDrive "archive-12" (USBHubPort 3) (Just "archive-older")
+ & autoMountDrive "passport" (USBHubPort 4) Nothing
& Apt.installed ["git-annex", "borgbackup"]
newtype USBHubPort = USBHubPort Int
@@ -1227,20 +1227,15 @@ newtype USBHubPort = USBHubPort Int
--
-- The hub port is turned on and off automatically as needed, using
-- uhubctl.
-autoMountDrive :: Mount.Label -> USBHubPort -> Property DebianLike
-autoMountDrive label (USBHubPort port) = propertyList desc $ props
+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
- & File.hasContent ("/etc/systemd/system/" ++ automount)
- [ "[Unit]"
- , "Description=Automount " ++ label
- , "[Automount]"
- , "Where=" ++ mountpoint
- , "TimeoutIdleSec=600"
- , "[Install]"
- , "WantedBy=multi-user.target"
- ]
+ & case malias of
+ Just t -> mountpoint `File.isSymlinkedTo`
+ File.LinkTarget ("/media/joey/" ++ t)
+ Nothing -> doNothing <!> doNothing
& File.hasContent ("/etc/systemd/system/" ++ mount)
[ "[Unit]"
, "Description=Mount " ++ label
@@ -1253,25 +1248,39 @@ autoMountDrive label (USBHubPort port) = propertyList desc $ props
, "[Install]"
, "WantedBy="
]
+ `onChange` Systemd.daemonReloaded
& File.hasContent ("/etc/systemd/system/" ++ hub)
[ "[Unit]"
, "Description=Startech usb hub port " ++ show port
, "PartOf=" ++ mount
, "[Service]"
, "Type=oneshot"
+ , "RemainAfterExit=true"
, "ExecStart=/usr/sbin/uhubctl -a on -p " ++ show port ++
-- short sleep to give the drive time to wake up before
-- it is mounted
" ; /bin/sleep 20"
- , "RemainAfterExit=true"
, "ExecStop=/usr/sbin/uhubctl -a off -p " ++ show port
, "[Install]"
, "WantedBy="
]
+ `onChange` Systemd.daemonReloaded
+ & File.hasContent ("/etc/systemd/system/" ++ automount)
+ [ "[Unit]"
+ , "Description=Automount " ++ label
+ , "[Automount]"
+ , "Where=" ++ mountpoint
+ , "TimeoutIdleSec=600"
+ , "[Install]"
+ , "WantedBy=multi-user.target"
+ ]
+ `onChange` Systemd.daemonReloaded
+ & Systemd.enabled automount
+ & Systemd.started automount
where
- desc = "auto mount drive " ++ label
+ mountpoint = "/media/joey/" ++ label
+ desc = "auto mount " ++ mountpoint
hub = "startech-hub-port-" ++ show port ++ ".service"
automount = svcbase ++ ".automount"
mount = svcbase ++ ".mount"
svcbase = Systemd.escapePath mountpoint
- mountpoint = "/media/joey/" ++ label