Statistics
| Revision:

root / tmp / trunk / org.txm.setups / shared / debian / usr / bin / TXM @ 741

History | View | Annotate | Download (5.4 kB)

1
# This script launches TXM in the right directory and with the right TXM.ini file
2
UBUNTU_MENUPROXY=0
3
VERSION=0.8.0
4

    
5
echo "TXM: Preparing redirections in $HOME/TXM_PostInstallOutputLogs.txt and $HOME/TXM_PostInstallErrorLogs.txt files."
6

    
7
LOGFILESMSG=", see $HOME/TXM_PostInstallOutputLogs.txt and $HOME/TXM_PostInstallErrorLogs.txt output and error messages files."
8

    
9
exec 3>$HOME/TXM_PostInstallOutputLogs.txt
10
exec 4>$HOME/TXM_PostInstallErrorLogs.txt
11

    
12
(
13
echo "TXM: $HOME is '$HOME'"
14

    
15
if [ ! -d "$HOME" ]; then
16
	zenity --info --text="TXM: Impossible to access user home directory ($HOME). Aborting"
17
	echo "TXM: Impossible to access user home directory ($HOME). Aborting"
18
	exit 1
19
fi
20

    
21
echo "TXM: Creating all necessary directories."
22

    
23
TXMHOME="$HOME/TXM_$VERSION"
24
echo "TXMHOME='$TXMHOME'"
25
if [ ! -d "$TXMHOME" ]; then
26
	mkdir "$TXMHOME"
27
fi
28
if [ ! -d "$TXMHOME" ]; then
29
	zenity --info --text="TXM: Impossible to access '$TXMHOME' directory. Aborting$LOGFILESMSG"
30
	echo "TXM: Impossible to access '$TXMHOME' directory. Aborting$LOGFILESMSG"
31
	exit 1
32
fi
33

    
34
DOTTXMHOME="$TXMHOME/.txm"
35
echo "DOTTXMHOME='$DOTTXMHOME'"
36
if [ ! -d "$DOTTXMHOME" ]; then
37
	mkdir "$DOTTXMHOME"
38
fi
39
if [ ! -d "$DOTTXMHOME" ]; then
40
	zenity --info --text="TXM: Impossible to access '$DOTTXMHOME' directory. Aborting$LOGFILESMSG"
41
	echo "TXM: Impossible to access '$DOTTXMHOME' directory. Aborting$LOGFILESMSG"
42
	exit 1
43
fi
44

    
45
echo "TXM: looking at the last TXM install date from the /usr/lib/TXM/STAMP file."
46

    
47
if [ ! -r "/usr/lib/TXM/STAMP" ]; then
48
	zenity --info --text="TXM: Impossible to access '/usr/lib/TXM/STAMP' file. Aborting$LOGFILESMSG"
49
	echo "TXM: Impossible to access '/usr/lib/TXM/STAMP' file. Aborting$LOGFILESMSG"
50
	exit 1
51
fi
52

    
53
STAMP=`stat -c %Y "/usr/lib/TXM/STAMP"`
54

    
55
if [ $? != 0 ]; then
56
    zenity --info --text="TXM: Impossible to get status of '/usr/lib/TXM/STAMP' file. Aborting$LOGFILESMSG"
57
    echo "TXM: Impossible to get status of '/usr/lib/TXM/STAMP' file. Aborting$LOGFILESMSG"
58
    exit 1
59
fi
60

    
61
echo "TXM: if .txm folder does not contain the $STAMP flag file, its a new install."
62
if [ ! -e "$HOME/TXM/.txm/$STAMP" ]; then
63

    
64
	echo "New TXM install: it's the first launch after the installation."
65
	if [ -f "/tmp/org.txm.rcpapplication.prefs" ]; then
66
		rm -f "/tmp/org.txm.rcpapplication.prefs" # remove previous preference files if any
67
	fi
68

    
69
	echo "Backing up previous TXM 0.7.6 preferences if any..."
70
	if [ -f "$HOME/.txm/configuration/.settings/org.txm.rcpapplication.prefs" ]; then
71
		echo "Found preference file: $HOME/.txm/configuration/.settings/org.txm.rcpapplication.prefs"
72
		cp -f "$HOME/.txm/configuration/.settings/org.txm.rcpapplication.prefs" "/tmp/org.txm.rcpapplication.prefs"
73
		if [ $? != 0 ]; then
74
  			echo "Failed to copy old preference file in /tmp/org.txm.rcpapplication.prefs"
75
		fi
76
	fi
77

    
78
	echo "Backing up previous TXM 0.7.7 preferences if any..."
79
	if [ -f "$HOME/.txm/data/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs" ]; then
80
		echo "Found preference file: $HOME/.txm/data/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs"
81
		cp -f "$HOME/.txm/data/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs" "/tmp/org.txm.rcpapplication.prefs"
82
		if [ $? != 0 ]; then
83
  			echo "Failed to copy old preference file in /tmp/org.txm.rcpapplication.prefs"
84
		fi
85
	fi
86

    
87
	echo "TXM: Installing up to date TXM directories."
88
	rm -rf "$HOME/TXM/.txm"
89
	if [ -d "$HOME/TXM/.txm" ]; then
90
	    zenity --info --text="TXM: Failed to remove $HOME/TXM/.txm directory$LOGFILESMSG"
91
	    echo "TXM: Failed to remove $HOME/TXM/.txm directory$LOGFILESMSG"
92
	    exit 1 ;
93
	fi
94

    
95
    mkdir "$HOME/TXM/.txm"
96
    if [ ! -d "$HOME/TXM/.txm" ]; then
97
		echo "TXM: Impossible to access '$HOME/TXM/.txm' directory. Aborting$LOGFILESMSG"
98
		exit 1
99
    fi
100
    
101
	mkdir "$HOME/TXM/.txm/user"
102
	if [ ! -d "$HOME/TXM/.txm/user" ]; then
103
		echo "TXM: Impossible to access '$HOME/TXM/.txm/user' directory. Aborting$LOGFILESMSG"
104
		exit 1
105
    fi
106
    
107
	mkdir "$HOME/TXM/.txm/data"
108
    if [ ! -d "$HOME/TXM/.txm/data" ]; then
109
		echo "TXM: Impossible to access '$HOME/TXM/.txm/data' directory. Aborting$LOGFILESMSG"
110
		exit 1
111
    fi
112
    
113
    mkdir "$HOME/TXM/.txm/configuration"
114
    if [ ! -d "$HOME/TXM/.txm/configuration" ]; then
115
		echo "TXM: Impossible to access '$HOME/TXM/.txm/configuration' directory. Aborting$LOGFILESMSG"
116
		exit 1
117
    fi
118

    
119
    echo "TXM: getting '/usr/lib/TXM/TXM.ini' and setting write permissions to '$HOME/TXM/.txm/TXM.ini'"
120
    cp "/usr/lib/TXM/TXM.ini" "$HOME/TXM/.txm/TXM.ini" &&
121
    chmod +w "$HOME/TXM/.txm/TXM.ini"
122
	
123
    if [ $? != 0 ]; then
124
        zenity --info --text="TXM: Can't launch TXM: failed to set TXM.ini file$LOGFILESMSG"
125
        echo "TXM: Can't launch TXM: failed to set TXM.ini file$LOGFILESMSG"
126
        exit 1
127
    fi
128

    
129
    echo "TXM: creating the $HOME/TXM/.txm/$STAMP flag file."
130
    touch "$HOME/TXM/.txm/$STAMP"
131

    
132
    if [ $? != 0 ]; then
133
        zenity --info --text="TXMLaunch: Can't launch TXM: failed to create the $HOME/TXM/.txm/$STAMP install STAMP file$LOGFILESMSG"
134
		echo "TXM: Can't launch TXM: failed to create the $HOME/TXM/.txm/$STAMP install STAMP file$LOGFILESMSG"
135
        exit 1
136
    fi
137
fi
138

    
139
) 1>&3 2>&4
140

    
141
# don't exec TXM if problem occurs
142
if [ $? != 0 ]; then
143
    echo "TXM: An error occurred. Aborting$LOGFILESMSG";
144
    exit 1 ;
145
fi
146

    
147
UBUNTU_MENUPROXY=0 exec /usr/lib/TXM/TXM -run --launcher.ini "$HOME/TXM/.txm/TXM.ini" -data "$HOME/TXM/.txm/data" -user "$HOME/TXM/.txm/user" -install "/usr/lib/TXM"