Skip to content

Commit

Permalink
Preserve Ubuntu L&F after install
Browse files Browse the repository at this point in the history
Closes #136
  • Loading branch information
tresf committed Feb 9, 2018
1 parent 9ed2203 commit d62ec8d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion ant/linux/linux-installer.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,32 @@ function restart_it() {
fi
}

# Provide user environmental variables to the sudo environment
function sudo_env() {
userid="$(logname 2>/dev/null || echo $SUDO_USER)"
pid=$(ps aux |grep "^$userid" |grep "dbus-daemon" | grep "unix:" |awk '{print $2}')
# Replace null delimiters with newline for grep
envt=$(cat "/proc/$pid/environ" |tr '\0' '\n')

# List of environmental variables to use; adjust as needed
# UPSTART_SESSION must come before GNOME_DESKTOP_SESSION_ID
exports=( "UPSTART_SESSION" "DISPLAY" "DBUS_SESSION_BUS_ADDRESS" "XDG_CURRENT_DESKTOP" "GNOME_DESKTOP_SESSION_ID" )

for i in "${exports[@]}"; do
# Re-set the variable within this session by name
# Careful, this technique won't yet work with spaces
if echo "$envt" | grep "^$i=" > /dev/null 2>&1; then
eval "$(echo "$envt" | grep "^$i=")" > /dev/null 2>&1
export $i > /dev/null 2>&1
elif initctl --user get-env $i > /dev/null 2>&1; then
eval "$i=$(initctl --user get-env $i)" > /dev/null 2>&1
export $i > /dev/null 2>&1
fi

echo "$i=${!i}"
done
}

# Check for Ubuntu to fix System Tray
grep -q "Ubuntu" /etc/lsb-release > /dev/null 2>&1
if [ $? -eq 0 ]; then
Expand Down Expand Up @@ -202,7 +228,9 @@ if [ $? -ne 0 ]; then
progress_dialog 100 "Finished. Please launch ${project.name} manually."
else
# Start ${project.name} as the user that's logged in
sudo -u $(logname 2>/dev/null || echo $SUDO_USER) nohup "java" ${launch.opts} -jar "${jarfile}" > /dev/null 2>&1 &
sudo_env
userid="$(logname 2>/dev/null || echo $SUDO_USER)"
sudo -E -u $userid nohup "java" ${launch.opts} -jar "${jarfile}" > /dev/null 2>&1 &
progress_dialog 100 "Finished. ${project.name} should start automatically."
fi
echo
Expand Down

0 comments on commit d62ec8d

Please sign in to comment.