Merge remote-tracking branch 'origin/github/pr/145'
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 90-update-alternatives
1 #!/bin/bash
2 # Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/90-update-alternatives
3 # Purpose:       set up /etc/alternatives/* according to grml preferences
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 ################################################################################
8
9 set -u
10 set -e
11
12 # starting with vim v2:8.1.2136-1 it uses /usr/libexec/vim for the vim.* binaries
13 if $ROOTCMD update-alternatives --list editor 2>/dev/null | grep -q /usr/libexec/vim ; then
14   VIM_PATH=/usr/libexec/vim
15 else # for backwards compatibility
16   VIM_PATH=/usr/bin
17 fi
18
19 if $ROOTCMD update-alternatives --list editor 2>/dev/null | grep -q 'vim.gtk3' ; then
20   echo "Setting vim.gtk3 as editor using update-alternatives."
21   $ROOTCMD update-alternatives --set editor "${VIM_PATH}"/vim.gtk3
22   $ROOTCMD update-alternatives --set vi     "${VIM_PATH}"/vim.gtk3
23   $ROOTCMD update-alternatives --set vim    "${VIM_PATH}"/vim.gtk3
24 elif $ROOTCMD update-alternatives --list editor 2>/dev/null | grep -q 'vim.gtk$' ; then
25   echo "Setting vim.gtk as editor using update-alternatives."
26   $ROOTCMD update-alternatives --set editor "${VIM_PATH}"/vim.gtk
27   $ROOTCMD update-alternatives --set vi     "${VIM_PATH}"/vim.gtk
28   $ROOTCMD update-alternatives --set vim    "${VIM_PATH}"/vim.gtk
29 elif $ROOTCMD update-alternatives --list editor 2>/dev/null | grep -q 'vim.basic' ; then
30   echo "Setting vim.basic as editor using update-alternatives."
31   $ROOTCMD update-alternatives --set editor "${VIM_PATH}"/vim.basic
32   $ROOTCMD update-alternatives --set vi     "${VIM_PATH}"/vim.basic
33   $ROOTCMD update-alternatives --set vim    "${VIM_PATH}"/vim.basic
34 elif $ROOTCMD update-alternatives --list editor 2>/dev/null | grep -q 'vim.tiny' ; then
35   echo "Setting vim.tiny as editor using update-alternatives."
36   $ROOTCMD update-alternatives --set editor "${VIM_PATH}"/vim.tiny
37   $ROOTCMD update-alternatives --set vi     "${VIM_PATH}"/vim.tiny
38 else
39   echo "Warning: No vim binary suitable for update-alternatives found."
40 fi
41
42 if $ROOTCMD update-alternatives --list x-terminal-emulator 2>/dev/null | grep -q '/uxterm' ; then
43   echo "Setting uxterm as x-terminal-emulator using update-alternatives."
44   $ROOTCMD update-alternatives --set x-terminal-emulator /usr/bin/uxterm
45 elif $ROOTCMD update-alternatives --list x-terminal-emulator 2>/dev/null | grep -q '/xterm' ; then
46   echo "Setting xterm as x-terminal-emulator using update-alternatives."
47   $ROOTCMD update-alternatives --set x-terminal-emulator /usr/bin/xterm
48 fi
49
50 if $ROOTCMD update-alternatives --list x-cursor-theme 2>/dev/null | grep -q '/whiteglass.theme' ; then
51   echo "Setting whiteglass.theme as x-cursor-theme using update-alternatives."
52   $ROOTCMD update-alternatives --set x-cursor-theme /etc/X11/cursors/whiteglass.theme
53 fi
54
55 if $ROOTCMD update-alternatives --list x-www-browser 2>/dev/null | grep -q '/iceweasel' ; then
56   echo "Setting iceweasel as x-www-browser using update-alternatives."
57   $ROOTCMD update-alternatives --set x-www-browser /usr/bin/iceweasel
58 fi
59
60 if $ROOTCMD update-alternatives --list x-www-browser 2>/dev/null | grep -q '/firefox-esr' ; then
61   echo "Setting firefox-esr as x-www-browser using update-alternatives."
62   $ROOTCMD update-alternatives --set x-www-browser /usr/bin/firefox-esr
63 fi
64
65 if $ROOTCMD update-alternatives --list www-browser 2>/dev/null | grep -q '/w3m' ; then
66   echo "Setting w3m as www-browser using update-alternatives."
67   $ROOTCMD update-alternatives --set www-browser /usr/bin/w3m
68 fi
69
70 if $ROOTCMD update-alternatives --list x-window-manager 2>/dev/null | grep -q '/wm-ng' ; then
71   echo "Setting wm-ng as x-window-manager using update-alternatives."
72   $ROOTCMD update-alternatives --set x-window-manager /usr/bin/wm-ng
73 fi
74
75 # sadly isn't available via update-alternates, anyway - use
76 # ntfs-3g (if available) as default for ntfs
77 if [ -r $target/sbin/mount.ntfs-3g ] || [ -L $target/sbin/mount.ntfs-3g ] ; then
78   $ROOTCMD ln -sf /sbin/mount.ntfs-3g /sbin/mount.ntfs
79 fi
80
81 ## END OF FILE #################################################################
82 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2