Created
June 8, 2014 15:55
-
-
Save dekarrin/ff67308f92111cb843e7 to your computer and use it in GitHub Desktop.
Scripts for fixing configs broken by installer
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/bash | |
| FILE_GRUB_DEFAULT=/etc/default/grub | |
| FILE_GRUB_CONF=/boot/grub/grub.cfg | |
| FILE_GRUB_BACKUP=.grub.cfg.bak | |
| if [ ! "$(id -u)" = "0" ] | |
| then | |
| echo "Script must be run as root!" | |
| else | |
| force= | |
| if [ "$#" -ge 1 -a "$1" = "-f" ] | |
| then | |
| force=1 | |
| fi | |
| if [ -f "$FILE_GRUB_BACKUP" -a -z "$force" ] | |
| then | |
| echo "Backup file already exists in '$FILE_GRUB_BACKUP'!" | |
| echo "Remove backup file or force with -f" | |
| else | |
| cp "$FILE_GRUB_CONF" "$FILE_GRUB_BACKUP" | |
| echo >> "$FILE_GRUB_CONF" | |
| echo "### BEGIN custom script '$0' ###" >> "$FILE_GRUB_CONF" | |
| . "$FILE_GRUB_DEFAULT" | |
| if [ -n "$GRUB_COLOR_NORMAL" ] | |
| then | |
| echo "set color_normal=$GRUB_COLOR_NORMAL" >> "$FILE_GRUB_CONF" | |
| fi | |
| if [ -n "$GRUB_COLOR_HIGHLIGHT" ] | |
| then | |
| echo "set color_highlight=$GRUB_COLOR_HIGHLIGHT" >> "$FILE_GRUB_CONF" | |
| fi | |
| if [ -n "$GRUB_MENU_COLOR_NORMAL" ] | |
| then | |
| echo "set menu_color_normal=$GRUB_MENU_COLOR_NORMAL" >> "$FILE_GRUB_CONF" | |
| fi | |
| if [ -n "$GRUB_MENU_COLOR_HIGHLIGHT" ] | |
| then | |
| echo "set menu_color_highlight=$GRUB_MENU_COLOR_HIGHLIGHT" >> "$FILE_GRUB_CONF" | |
| fi | |
| echo "### END custom script '$0' ###" >> "$FILE_GRUB_CONF" | |
| echo "Added neccessary changes" | |
| echo "Original backed up at '$FILE_GRUB_BACKUP'" | |
| fi | |
| 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/bash | |
| PULSE_INIT=/etc/init.d/pulseaudio | |
| PULSE_TEMP=pulseaudio.temp | |
| PULSE_BU=.pulseaudio.bak | |
| P_START='if \[ "\$PULSEAUDIO_SYSTEM_START" != "' | |
| P_END='" ]' | |
| PATTERN="$P_START"1"$P_END" | |
| PATTERN_REPLACED="$P_START"0"$P_END" | |
| PATTERN_BACKREF='\('"$P_START"'\)'1'\('"$P_END"'\)' | |
| PATTERN_CLOSE='^fi$' | |
| if [ ! "$(id -u)" -eq "0" ] | |
| then | |
| echo "Script must be run as root!" | |
| else | |
| force= | |
| if [ "$#" -ge 1 -a "$1" = "-f" ] | |
| then | |
| force=1 | |
| fi | |
| if [ -f "$PULSE_BU" -a -z "$force" ] | |
| then | |
| echo "Backup from previous run already exists in '$PULSE_BU'!" | |
| echo "Remove remove backup file or force with -f" | |
| else | |
| sed -e 's/'"$PATTERN_BACKREF"'/\10\2/' \ | |
| -e 's/system-wide/OLD_SYS/g' \ | |
| -e 's/per-user/system-wide/g' \ | |
| -e 's/OLD_SYS/per-user/g' \ | |
| -e '/'"$PATTERN_REPLACED"'/,/'"$PATTERN_CLOSE"'/ s/\(\s*\)exit 0/else\n\1exit 0/g' \ | |
| "$PULSE_INIT" > "$PULSE_TEMP" | |
| cp "$PULSE_INIT" "$PULSE_BU" | |
| mv "$PULSE_TEMP" "$PULSE_INIT" | |
| chmod 755 "$PULSE_INIT" | |
| echo "Made changes to '$PULSE_INIT'" | |
| echo "Backup is in '$PULSE_BU'" | |
| echo "Examine to ensure correctness" | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment