Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- echo 'Warning: This patch depends on: acroread, sed, sudo.'
- echo 'Optionally, for a GUI, it depends on gksu and notify-send.'
- COMMENTING="Applying patch..."
- UNCOMMENTING="Patch worked. Reversing patch..."
- FIX_NOT_RUN_SUMMARY="The Adobe Reader patch did not run!"
- FIX_NOT_RUN_DESC="The patch needs ROOT permission to edit your /etc/hosts file."
- CMD_CMMT='sed -i "/::1/ s/^/# /" /etc/hosts'
- # Check for running instance
- if pidof -x "acroread" >/dev/null; then
- echo "Adobe Reader already running, skipping patch!"
- notify-send "Adobe Reader already running, skipping patch!"
- acroread "$1"
- exit 0
- fi
- if [[ $DISPLAY ]] && ! tty; then
- #Invocation from GUI
- notify-send "$COMMENTING"
- gksu --message "$FIX_NOT_RUN_DESC" "$CMD_CMMT";
- if [ $? -eq 0 ]; then
- notify-send --icon=dialog-error "$FIX_NOT_RUN_SUMMARY" "$FIX_NOT_RUN_DESC";
- exit 126;
- fi
- else
- #Invocation from terminal
- echo "$COMMENTING"
- sudo sed -i "/::1/ s/^/# /" /etc/hosts || { echo "$FIX_NOT_RUN_DESC"; exit 126; }
- fi
- #Launch Adobe Reader in the background
- nohup acroread "$1" &>/dev/null &disown
- echo 'Waiting for Reader...'
- sleep 5
- if [[ $DISPLAY ]] && ! tty; then
- #Invocation from GUI
- notify-send "$UNCOMMENTING"
- sed -i "/::1/ s/# *//" /etc/hosts
- else
- #Invocation from terminal
- echo "$UNCOMMENTING"
- sudo sed -i "/::1/ s/# *//" /etc/hosts
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement