90-update-alternatives: check for available alternatives before setting them.
[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 if $ROOTCMD update-alternatives --list editor 2>/dev/null | grep -q vim.gtk ; then
13   echo "Setting vim.gtk as editor using update-alternatives."
14   $ROOTCMD update-alternatives --set editor /usr/bin/vim.gtk
15   $ROOTCMD update-alternatives --set vi     /usr/bin/vim.gtk
16   $ROOTCMD update-alternatives --set vim    /usr/bin/vim.gtk
17   $ROOTCMD update-alternatives --set view   /usr/bin/vim.gtk
18 elif $ROOTCMD update-alternatives --list editor 2>/dev/null | grep -q vim.basic ; then
19   echo "Setting vim.basic as editor using update-alternatives."
20   $ROOTCMD update-alternatives --set editor /usr/bin/vim.basic
21   $ROOTCMD update-alternatives --set vi     /usr/bin/vim.basic
22   $ROOTCMD update-alternatives --set vim    /usr/bin/vim.basic
23   $ROOTCMD update-alternatives --set view   /usr/bin/vim.basic
24 elif $ROOTCMD update-alternatives --list editor 2>/dev/null | grep -q vim.tiny ; then
25   echo "Setting vim.tiny as editor using update-alternatives."
26   $ROOTCMD update-alternatives --set editor /usr/bin/vim.tiny
27   $ROOTCMD update-alternatives --set vi     /usr/bin/vim.tiny
28   $ROOTCMD update-alternatives --set vim    /usr/bin/vim.tiny
29   $ROOTCMD update-alternatives --set view   /usr/bin/vim.tiny
30 else
31   echo "Warning: No vim binary suitable for update-alternatives found."
32 fi
33
34 if $ROOTCMD update-alternatives --list x-terminal-emulator 2>/dev/null | grep -q '/uxterm' ; then
35   echo "Setting uxterm as x-terminal-emulator using update-alternatives."
36   $ROOTCMD update-alternatives --set x-terminal-emulator /usr/bin/uxterm
37 elif $ROOTCMD update-alternatives --list x-terminal-emulator 2>/dev/null | grep -q '/xterm' ; then
38   echo "Setting xterm as x-terminal-emulator using update-alternatives."
39   $ROOTCMD update-alternatives --set x-terminal-emulator /usr/bin/xterm
40 fi
41
42 if $ROOTCMD update-alternatives --list x-cursor-theme 2>/dev/null | grep -q '/whiteglass.theme' ; then
43   echo "Setting whiteglass.theme as x-cursor-theme using update-alternatives."
44   $ROOTCMD update-alternatives --set x-cursor-theme /etc/X11/cursors/whiteglass.theme
45 fi
46
47 if $ROOTCMD update-alternatives --list x-www-browser 2>/dev/null | grep -q '/iceweasel' ; then
48   echo "Setting iceweasel as x-www-browser using update-alternatives."
49   $ROOTCMD update-alternatives --set x-www-browser /usr/bin/iceweasel
50 fi
51
52 if $ROOTCMD update-alternatives --list www-browser 2>/dev/null | grep -q '/w3m' ; then
53   echo "Setting w3m as www-browser using update-alternatives."
54   $ROOTCMD update-alternatives --set www-browser /usr/bin/w3m
55 fi
56
57 if $ROOTCMD update-alternatives --list x-window-manager 2>/dev/null | grep -q '/wm-ng' ; then
58   echo "Setting wm-ng as x-window-manager using update-alternatives."
59   $ROOTCMD update-alternatives --set x-window-manager /usr/bin/wm-ng
60 fi
61
62 # sadly isn't available via update-alternates, anyway - use
63 # ntfs-3g (if available) as default for ntfs
64 if [ -r $target/sbin/mount.ntfs-3g ] || [ -L $target/sbin/mount.ntfs-3g ] ; then
65   $ROOTCMD ln -sf /sbin/mount.ntfs-3g /sbin/mount.ntfs
66 fi
67
68 ## END OF FILE #################################################################
69 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2