Skip to content

Commit

Permalink
6: etc/*
Browse files Browse the repository at this point in the history
Signed-off-by: Jorgen Lundman <[email protected]>
  • Loading branch information
lundman authored and andrewc12 committed Oct 24, 2023
1 parent a633606 commit 85f5dc7
Show file tree
Hide file tree
Showing 15 changed files with 937 additions and 0 deletions.
1 change: 1 addition & 0 deletions etc/launchd.d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zpool-import-all.sh
19 changes: 19 additions & 0 deletions etc/launchd.d/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

noinst_launch_d_DATA = \
%D%/zpool-import-all.sh.in
noinst_launch_ddir = \
$(launchdscriptdir)/

do_subst = -$(SED) -e 's,@bindir\@,$(bindir),g' \
-e 's,@runstatedir\@,$(runstatedir),g' \
-e 's,@sbindir\@,$(sbindir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
-e 's,@launchdscriptdir\@,$(launchdscriptdir),g'

CLEANFILES += %D%/zpool-import-all.sh

INSTALL_DATA_HOOKS += install-zpool-import

install-zpool-import: %D%/zpool-import-all.sh.in
$(do_subst) < %D%/zpool-import-all.sh.in > $(DESTDIR)/$(launchdscriptdir)/zpool-import-all.sh
chmod +x $(DESTDIR)/$(launchdscriptdir)/zpool-import-all.sh
60 changes: 60 additions & 0 deletions etc/launchd.d/zpool-import-all.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

echo "+zpool-import-all.sh"
date
export ZPOOL_IMPORT_ALL_COOKIE=/var/run/org.openzfsonosx.zpool-import-all.didRun
export INVARIANT_DISKS_IDLE_FILE=/var/run/disk/invariant.idle
export TIMEOUT_SECONDS=60
export MAXIMUM_SLEEP_ITERATIONS=$((${TIMEOUT_SECONDS} * 10))

/usr/bin/time /usr/sbin/system_profiler SPParallelATADataType SPCardReaderDataType SPFibreChannelDataType SPFireWireDataType SPHardwareRAIDDataType SPNetworkDataType SPPCIDataType SPParallelSCSIDataType SPSASDataType SPSerialATADataType SPStorageDataType SPThunderboltDataType SPUSBDataType SPNetworkVolumeDataType 1>/dev/null 2>&1

/bin/sync

echo "Waiting up to ${TIMEOUT_SECONDS} seconds for the InvariantDisks idle file ${INVARIANT_DISKS_IDLE_FILE} to exist"

i=0
while [ "${i}" -lt "${MAXIMUM_SLEEP_ITERATIONS}" -a ! -e "${INVARIANT_DISKS_IDLE_FILE}" ]
do
i=$((i+1))
sleep .1
done

if [ -e "${INVARIANT_DISKS_IDLE_FILE}" ]
then
echo "Found ${INVARIANT_DISKS_IDLE_FILE} after ${i} iterations of sleeping 0.1 seconds"
else
echo "File ${INVARIANT_DISKS_IDLE_FILE} not found within ${TIMEOUT_SECONDS} seconds"
fi
date

if [ -f "@sysconfdir@/zfs/zsysctl.conf" ]; then
@sbindir@/zsysctl -f @sysconfdir@/zfs/zsysctl.conf
fi

# check to see if we have been instructed not to try to import at all
if [ -f /etc/zfs/noautoimport ];
then
echo "/etc/zfs/noautoimport exits, exiting";
exit 0;
fi

date
echo "-zpool-import-all.sh"

sleep 10
echo "Loading and starting org.openzfsonosx.zpool-import"
date

/bin/launchctl load /Library/LaunchDaemons/org.openzfsonosx.zpool-import.plist
/bin/launchctl kickstart -kp system/org.openzfsonosx.zpool-import

echo Status: $?

echo "Touching the file ${ZPOOL_IMPORT_ALL_COOKIE}"
touch "${ZPOOL_IMPORT_ALL_COOKIE}"

date
echo "-zpool-import-all.sh"

exit 0
4 changes: 4 additions & 0 deletions etc/launchd/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
launchddaemondir = /Library/LaunchDaemons
launchdscriptdir = ${libexecdir}/zfs/launchd.d

include $(srcdir)/%D%/daemons/Makefile.am
5 changes: 5 additions & 0 deletions etc/launchd/daemons/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
org.openzfsonosx.zconfigd.plist
org.openzfsonosx.zed.plist
org.openzfsonosx.zpool-import.plist
org.openzfsonosx.zpool-import-all.plist
org.openzfsonosx.InvariantDisks.plist
33 changes: 33 additions & 0 deletions etc/launchd/daemons/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

CLEANFILES += $(launchddaemon_DATA)

launchddaemon_DATA = \
$(top_srcdir)/etc/launchd/daemons/org.openzfsonosx.zconfigd.plist \
$(top_srcdir)/etc/launchd/daemons/org.openzfsonosx.zed.plist \
$(top_srcdir)/etc/launchd/daemons/org.openzfsonosx.zpool-import.plist \
$(top_srcdir)/etc/launchd/daemons/org.openzfsonosx.zpool-import-all.plist \
$(top_srcdir)/etc/launchd/daemons/org.openzfsonosx.InvariantDisks.plist

dist_launchddaemon_DATA = \
%D%/org.openzfsonosx.zconfigd.plist.in \
%D%/org.openzfsonosx.zed.plist.in \
%D%/org.openzfsonosx.zpool-import.plist.in \
%D%/org.openzfsonosx.zpool-import-all.plist.in \
%D%/org.openzfsonosx.InvariantDisks.plist.in

%D%/org.openzfsonosx.zconfigd.plist: %D%/org.openzfsonosx.zconfigd.plist.in
%D%/org.openzfsonosx.zed.plist: %D%/org.openzfsonosx.zed.plist.in
%D%/org.openzfsonosx.zpool-import.plist: %D%/org.openzfsonosx.zpool-import.plist.in
%D%/org.openzfsonosx.zpool-import-all.plist: %D%/org.openzfsonosx.zpool-import-all.plist.in
%D%/org.openzfsonosx.InvariantDisks.plist: %D%/org.openzfsonosx.InvariantDisks.plist.in

$(launchddaemon_DATA):
-$(SED) -e 's,@bindir\@,$(bindir),g' \
-e 's,@runstatedir\@,$(runstatedir),g' \
-e 's,@sbindir\@,$(sbindir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
-e 's,@launchddaemondir\@,$(launchddaemondir),g' \
-e 's,@launchdscriptdir\@,$(launchdscriptdir),g' \
'[email protected]' >'$@'


16 changes: 16 additions & 0 deletions etc/launchd/daemons/org.openzfsonosx.InvariantDisks.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openzfsonosx.InvariantDisks</string>
<key>ProgramArguments</key>
<array>
<string>@sbindir@/InvariantDisks</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
20 changes: 20 additions & 0 deletions etc/launchd/daemons/org.openzfsonosx.zconfigd.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openzfsonosx.zconfigd</string>
<key>ProgramArguments</key>
<array>
<string>@sbindir@/zconfigd</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/private/var/log/org.openzfsonosx.zconfigd.err</string>
<key>StandardOutPath</key>
<string>/private/var/log/org.openzfsonosx.zconfigd.log</string>
</dict>
</plist>
21 changes: 21 additions & 0 deletions etc/launchd/daemons/org.openzfsonosx.zed.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openzfsonosx.zed</string>
<key>ProgramArguments</key>
<array>
<string>@sbindir@/zed</string>
<string>-vfF</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/private/var/log/org.openzfsonosx.zed.err</string>
<key>StandardOutPath</key>
<string>/private/var/log/org.openzfsonosx.zed.log</string>
</dict>
</plist>
18 changes: 18 additions & 0 deletions etc/launchd/daemons/org.openzfsonosx.zpool-import-all.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openzfsonosx.zpool-import-all</string>
<key>ProgramArguments</key>
<array>
<string>@launchdscriptdir@/zpool-import-all.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/private/var/log/org.openzfsonosx.zpool-import-all.err</string>
<key>StandardOutPath</key>
<string>/private/var/log/org.openzfsonosx.zpool-import-all.log</string>
</dict>
</plist>
24 changes: 24 additions & 0 deletions etc/launchd/daemons/org.openzfsonosx.zpool-import.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openzfsonosx.zpool-import</string>
<key>ProgramArguments</key>
<array>
<string>@sbindir@/zpool</string>
<string>import</string>
<string>-a</string>
<string>-d</string>
<string>/var/run/disk/by-id</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>LaunchOnlyOnce</key>
<false/>
<key>StandardErrorPath</key>
<string>/private/var/log/org.openzfsonosx.zpool-import-all.log</string>
<key>StandardOutPath</key>
<string>/private/var/log/org.openzfsonosx.zpool-import-all.log</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions etc/paths.d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zfs-path
20 changes: 20 additions & 0 deletions etc/paths.d/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pathsddir = $(sysconfdir)/paths.d
pathsd_DATA = %D%/zfs-path

paths_ddir = $(sysconfdir)/paths.d/
dist_paths_d_DATA = \
%D%/zfs-path

zfs-path: %D%/zfs-path.in

CLEANFILES += $(pathsd_DATA)
CLEANFILES += %D%/zfs-path
INSTALL_DATA_HOOKS += pathsd-data-hook
pathsd-data-hook: %D%/zfs-path.in
-$(SED) -e 's,@bindir\@,$(bindir),g' \
-e 's,@runstatedir\@,$(runstatedir),g' \
-e 's,@sbindir\@,$(sbindir),g' \
-e 's,@sysconfdir\@,$(sysconfdir),g' \
-e 's,@launchddaemondir\@,$(launchddaemondir),g' \
-e 's,@launchdscriptdir\@,$(launchdscriptdir),g' \
%D%/zfs-path.in > $(DESTDIR)/$(sysconfdir)/paths.d/zfs-path
2 changes: 2 additions & 0 deletions etc/paths.d/zfs-path.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@bindir@
@sbindir@
Loading

0 comments on commit 85f5dc7

Please sign in to comment.