Created
October 18, 2016 14:29
-
-
Save gburd/5766d4cd504c3da30980d23f0dc676b7 to your computer and use it in GitHub Desktop.
Ubuntu 16.06 - rc.local tricks/tips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure that Google Chrome's script terminates subprocesses (like 'cat') properly | |
( if ! grep -q 'trap \"trap - SIGTERM && kill -- -$$\" SIGINT SIGTERM EXIT' /opt/google/chrome/google-chrome | |
then | |
LINE=$(( $(awk '$0 ~ "exec 2" {print NR}' /opt/google/chrome/google-chrome) + 1)) | |
/bin/ed /opt/google/chrome/google-chrome <<EOF | |
${LINE}i | |
trap "trap - SIGTERM && kill -- -\$\$" SIGINT SIGTERM EXIT | |
. | |
w | |
q | |
EOF | |
fi ) & |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# | |
# rc.local | |
# | |
# This script is executed at the end of each multiuser runlevel. | |
# Make sure that the script will "exit 0" on success or any other | |
# value on error. | |
# | |
# In order to enable or disable this script just change the execution | |
# bits. | |
# | |
# Use these settings to allow for CPU frequency scaling. | |
echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor | |
echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice | |
# Enable kernel memory de-duper (called Kernel Same-page Merging, or KSM) | |
echo 1 >/sys/kernel/mm/ksm/run | |
echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs | |
# Check to see if we're on the QNET | |
if ! ip route get 8.8.8.8 | awk '{print $NF; exit}' | grep -q ^172.; then | |
# Try one last time to get the assignment from the DHCP server. | |
dhclient && service sign restart | |
fi | |
# Set my Time Zone. | |
timedatectl set-timezone $(curl -s http://freegeoip.net/json/$(dig +short myip.opendns.com @resolver1.opendns.com) | jq '.time_zone' | tr -d '"') | |
# Synchronize network time. | |
( /etc/init.d/ntp stop | |
until ping -nq -c3 8.8.8.8; do | |
echo "Waiting for network..." | |
done | |
ntpd -gq | |
# or: `ntpdate -b -s 0.pool.ntp.org` | |
/etc/init.d/ntp start )& | |
# Set the core file pattern to be *much* more useful when debugging. | |
echo 'core_dump.file_name(%e).signal(%s).size(%c).process_id(%p).uid(%u).gid(%g).time(%t).initial_pid(%P).thread_id(%I)' > /proc/sys/kernel/core_pattern | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment