summaryrefslogtreecommitdiff
path: root/nautilus-installer/src/prescript
blob: 36a4441b5fba255e6c9609f7dc33cb07deb6d148 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
if test x$DISPLAY = x; then
    echo "Eazel Installer requires X to be running."
    exit
fi
export="export DISPLAY botan_rice_candy"
params="DISPLAY=$DISPLAY && botan_rice_candy=yum"

# Check proxy settings
if test x$http_proxy '!=' x; then
    export="$export http_proxy"
    params="$params && http_proxy=$http_proxy"
fi

# Figure out what is already installed
PR1_TO_PR2=no
if test -f /usr/bin/nautilus; then
    VERSION=`/usr/bin/nautilus --version`
    if [ "x$VERSION" = "xGnome nautilus 0.1.0" ]; then
        PR1_TO_PR2=yes
    fi
fi

if test "x$1" = "x--version" -o "x$1" = "x--build" -o "x$1" = "x--help"; then
    QUICK=yes
fi

# First time through?  spam...
if test "x$botan_rice_candy" = "x" -a "x$QUICK" '!=' "xyes"; then
    # blurp 
    echo ""
    echo "Eazel Installer 1.0"
    echo ""
    if test "x$PR1_TO_PR2" = "xyes"; then
        echo "Your PR1 setttings will be moved to ~/.nautilus.pr2.backup..."
        echo ""
    fi
fi

if test $UID -ne 0 -a "x$QUICK" '!=' "xyes"; then
    echo "To use the Eazel installer, you need superuser (root) access to your system."
    echo "If you are prompted for your root password, please enter it to login as the"
    echo "superuser.  The root password is used only on your local machine, and is not"
    echo "transmitted to Eazel or any other party."
    echo ""

    # Start
    xhost +localhost
    /bin/su -s /bin/sh -c "$params && $export && cd $PWD && echo Uncompressing... && /bin/sh $0 $* --user $USER"
    xhost -localhost

    # FIXME: this will only work if they didn't run as root.
    # Move config
    if test "x$PR1_TO_PR2" = "xyes"; then
        VERSION=`/usr/bin/nautilus --version`
        if test "x$VERSION" != "xGNOME nautilus 0.1.0"; then
            echo "Saving old settings..."
            mkdir -p $HOME/.nautilus.pr2.backup >& /dev/null
            mv -f $HOME/.nautilus $HOME/.nautilus.pr2.backup/ >& /dev/null
            mv -f $HOME/Nautilus $HOME/.nautilus.pr2.backup/ >& /dev/null
            mv -f $HOME/.gconf/apps/nautilus/ $HOME/.nautilus.pr2.backup/ >& /dev/null
            mv -f $HOME/.gconf/apps/eazel-trilobite/ $HOME/.nautilus.pr2.backup/ >& /dev/null
        fi
    fi
    exit
else
    if test "x$botan_rice_candy" = "x"; then
        # running as root, or has "--{version|build|help}" command-line option
        # note that the --user option has to be of the '=' variety because of
        # a bug in popt. (if any of the user args use the '=' form, a final
        # non-'=' ['--user arg'] option silently corrupts argv.)
	/bin/sh -c "$params && $export && cd $PWD && /bin/sh $0 $* --user=$USER"
	exit
    fi
fi