-
Notifications
You must be signed in to change notification settings - Fork 6
/
install_macos_sysctl.sh
86 lines (86 loc) · 2.49 KB
/
install_macos_sysctl.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
#
# Shawn Ostermann - Ohio University
# Version 0.9 - Jan 29, 2021
# Version 1.1 - Mar 16, 2023
#
# Starting with Macos Catalina (10.15), MacOS no longer runs the commands in the /etc/sysctl.conf file
# This shell script will create a launchtl plist file that will run the 4 sysctl commands needed for ION every
# time a Mac reboots
#
# expanded in 2023 to be big enough that all of the demos/bench* tests pass on a fast M1 Mac
#
if [[ -z `uname -a | grep Darwin` ]]; then
echo "This is only needed on a Mac" 1>&2
exit 1
fi
#
PLISTNAME="com.ion.launched.ion_shared_memory.plist"
PLISTHOME="/Library/LaunchDaemons"
PLISTFULLDIR="${PLISTHOME}/${PLISTNAME}"
#
# create the plist file in /tmp
#
echo "If this file is run as root, it will actually do the installation."
echo "If that makes you nervous (and it should), just run as yourself and then run the 2 failing lines with sudo"
#
#
echo "========"
echo "Creating Plist file ${PLISTNAME} in /tmp"
#
cat > /tmp/${PLISTNAME} <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ion.launched.ion_shared_memory</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>\
/usr/sbin/sysctl kern.sysv.shmseg=32; \
/usr/sbin/sysctl kern.sysv.shmall=1048576; \
/usr/sbin/sysctl net.inet.udp.maxdgram=655360; \
/usr/sbin/sysctl kern.sysv.shmmax=2147483648; \
</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string>
</dict>
</plist>
EOF
#
#
#
# install the file
#
echo "========"
echo "Trying to install the file into ${PLISTHOME}"
echo "(this command will fail if not run as root - in which case, just run it yourself with sudo)"
sh -x -c "cp /tmp/${PLISTNAME} ${PLISTFULLDIR}"
#
# activate the file with launchctl
#
echo "========"
echo "Trying to install the file permanently with Launchctl"
echo "(this command will fail if not run as root - in which case, just run it yourself with sudo)"
sh -x -c "launchctl load -w ${PLISTFULLDIR}"
#
#
echo "========"
echo "Current Settings:"
/usr/sbin/sysctl kern.sysv.shmseg
/usr/sbin/sysctl kern.sysv.shmall
/usr/sbin/sysctl net.inet.udp.maxdgram
/usr/sbin/sysctl kern.sysv.shmmax
#
echo
echo "To change these settings later, you can either"
echo " 1) edit this script and change the values, then run it again, then reboot"
echo " or 2) edit the file as root: $PLISTFULLDIR then reboot"
#
exit 0