Package tuned: Scripts

Post install

/usr/sbin/post_service tuned

# convert active_profile from full path to name (if needed)
sed -i 's|.*/\([^/]\+\)/[^\.]\+\.conf|\1|' /etc/tuned/active_profile

# convert GRUB_CMDLINE_LINUX to GRUB_CMDLINE_LINUX_DEFAULT
if [ -r /etc/sysconfig/grub2 ]; then
	sed -i 's/GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX \\$tuned_params"/GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT \\$tuned_params"/' \
	  /etc/sysconfig/grub2
fi

# conditional support for grub2, grub2 is not available on all architectures
# and tuned is noarch package, thus the following hack is needed
if [ -d /etc/grub.d ]; then
	cp -a /usr/share/tuned/grub2/00_tuned /etc/grub.d/00_tuned
fi
Post uninstall

if [ $1 -eq 0 ]; then
	rm -f /etc/grub.d/00_tuned || :

	# unpatch /etc/default/grub
	if [ -r /etc/sysconfig/grub2 ]; then
		sed -i '/GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT:+$GRUB_CMDLINE_LINUX_DEFAULT }\\$tuned_params"/d' \
		  /etc/sysconfig/grub2
	fi
	# cleanup for Boot loader specification (BLS)

	# clear grubenv variables
	GRUBEDITENV=grub-editenv
	$GRUBEDITENV - unset tuned_params tuned_initrd &>/dev/null || :

	# unpatch BLS entries
	MACHINE_ID=`cat /etc/machine-id 2>/dev/null`
	if [ "$MACHINE_ID" ]; then
		for f in /boot/loader/entries/$MACHINE_ID-*.conf; do
			if [ -f "$f" -a "${f: -12}" != "-rescue.conf" ]; then
				sed -i '/^\s*options\s\+.*\$tuned_params/ s/\s\+\$tuned_params\b//g' "$f" &>/dev/null || :
				sed -i '/^\s*initrd\s\+.*\$tuned_initrd/ s/\s\+\$tuned_initrd\b//g' "$f" &>/dev/null || :
			fi
		done
	fi
fi
Pre uninstall

1
2
3
4
5
6
7
/usr/sbin/preun_service tuned
if [ $1 -eq 0 ] ; then
	# clear persistent storage
	rm -f /var/lib/tuned/* || :
	# clear temporal storage
	rm -f /run/tuned/* || :
fi