Statistics
| Revision:

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

History | View | Annotate | Download (5.7 kB)

1
# This script launches TXM in the right directory and with the right TXM.ini file
2
UBUNTU_MENUPROXY=0
3
VERSION=-TXMVERSION
4
VERSIONWITHOUTSUB=-TXMVERSIONWITHOUTSUB
5

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

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

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

    
13
TXMINSTALL="/usr/lib/TXM${VERSION}"
14
TXMHOME="$HOME/TXM${VERSIONWITHOUTSUB}"
15
DOTTXMHOME="$HOME/.TXM${VERSIONWITHOUTSUB}"
16

    
17
(
18
echo "TXM: $HOME is '$HOME'"
19

    
20
if [ ! -d "$HOME" ]; then
21
	zenity --info --text="TXM: Impossible to access user home directory ($HOME). Aborting"
22
	echo "TXM: Impossible to access user home directory ($HOME). Aborting"
23
	exit 1
24
fi
25

    
26
echo "TXM: Creating all necessary directories."
27

    
28
echo "TXMHOME='$TXMHOME'"
29
if [ ! -d "$TXMHOME" ]; then
30
	mkdir "$TXMHOME"
31
fi
32
if [ ! -d "$TXMHOME" ]; then
33
	zenity --info --text="TXM: Impossible to access '$TXMHOME' directory. Aborting$LOGFILESMSG"
34
	echo "TXM: Impossible to access '$TXMHOME' directory. Aborting$LOGFILESMSG"
35
	exit 1
36
fi
37

    
38

    
39
echo "DOTTXMHOME='$DOTTXMHOME'"
40
if [ ! -d "$DOTTXMHOME" ]; then
41
	mkdir "$DOTTXMHOME"
42
fi
43
if [ ! -d "$DOTTXMHOME" ]; then
44
	zenity --info --text="TXM: Impossible to access '$DOTTXMHOME' directory. Aborting$LOGFILESMSG"
45
	echo "TXM: Impossible to access '$DOTTXMHOME' directory. Aborting$LOGFILESMSG"
46
	exit 1
47
fi
48

    
49
echo "TXM: looking at the last TXM install date from the /usr/lib/TXM${VERSION}/STAMP file."
50

    
51
if [ ! -r "$TXMINSTALL/STAMP" ]; then
52
	zenity --info --text="TXM: Impossible to access '$TXMINSTALL/STAMP' file. Aborting$LOGFILESMSG"
53
	echo "TXM: Impossible to access '$TXMINSTALL/STAMP' file. Aborting$LOGFILESMSG"
54
	exit 1
55
fi
56

    
57
STAMP=`stat -c %Y "$TXMINSTALL/STAMP"`
58

    
59
if [ $? != 0 ]; then
60
    zenity --info --text="TXM: Impossible to get status of '$TXMINSTALL/STAMP' file. Aborting$LOGFILESMSG"
61
    echo "TXM: Impossible to get status of '$TXMINSTALL/STAMP' file. Aborting$LOGFILESMSG"
62
    exit 1
63
fi
64

    
65
echo "TXM: if .txm folder does not contain the $STAMP flag file, its a new install."
66
if [ ! -e "$DOTTXMHOME/$STAMP" ]; then
67

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

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

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

    
91
	echo "TXM: Installing up to date TXM directories."
92
	rm -rf "$DOTTXMHOME"
93
	if [ -d "$DOTTXMHOME" ]; then
94
	    zenity --info --text="TXM: Failed to remove $DOTTXMHOME directory$LOGFILESMSG"
95
	    echo "TXM: Failed to remove $DOTTXMHOME directory$LOGFILESMSG"
96
	    exit 1 ;
97
	fi
98
	
99
	echo "TXM: resetting RCP workspace."
100
	rm -rf "$TXMHOME/.metadata"
101
	if [ -d "$TXMHOME/.metadata" ]; then
102
	    zenity --info --text="TXM: Failed to remove $TXMHOME/.metadata"
103
	    echo "TXM: Failed to remove $TXMHOME/.metadata"
104
	    exit 1 ;
105
	fi
106

    
107
    mkdir "$DOTTXMHOME"
108
    if [ ! -d "$DOTTXMHOME" ]; then
109
		echo "TXM: Impossible to access '$DOTTXMHOME' directory. Aborting$LOGFILESMSG"
110
		exit 1
111
    fi
112
    
113
	mkdir "$DOTTXMHOME/user"
114
	if [ ! -d "$DOTTXMHOME/user" ]; then
115
		echo "TXM: Impossible to access '$DOTTXMHOME/user' directory. Aborting$LOGFILESMSG"
116
		exit 1
117
    fi
118
    
119
    mkdir "$DOTTXMHOME/configuration"
120
    if [ ! -d "$DOTTXMHOME/configuration" ]; then
121
		echo "TXM: Impossible to access '$DOTTXMHOME/configuration' directory. Aborting$LOGFILESMSG"
122
		exit 1
123
    fi
124

    
125
    echo "TXM: getting '$TXMINSTALL/TXM.ini' and setting write permissions to '$DOTTXMHOME/TXM.ini'"
126
    cp "$TXMINSTALL/TXM.ini" "$DOTTXMHOME/TXM.ini" &&
127
    chmod +w "$DOTTXMHOME/TXM.ini"
128
	
129
    if [ $? != 0 ]; then
130
        zenity --info --text="TXM: Can't launch TXM: failed to set TXM.ini file$LOGFILESMSG"
131
        echo "TXM: Can't launch TXM: failed to set TXM.ini file$LOGFILESMSG"
132
        exit 1
133
    fi
134

    
135
    echo "TXM: creating the $DOTTXMHOME/$STAMP flag file."
136
    touch "$DOTTXMHOME/$STAMP"
137

    
138
    if [ $? != 0 ]; then
139
        zenity --info --text="TXMLaunch: Can't launch TXM: failed to create the $DOTTXMHOME/$STAMP install STAMP file$LOGFILESMSG"
140
		echo "TXM: Can't launch TXM: failed to create the $DOTTXMHOME/$STAMP install STAMP file$LOGFILESMSG"
141
        exit 1
142
    fi
143
else
144
	echo "TXM: already up to date."
145
fi
146

    
147
) 1>&3 2>&4
148

    
149
# don't exec TXM if problem occurs
150
if [ $? != 0 ]; then
151
    echo "TXM: An error occurred. Aborting$LOGFILESMSG"
152
    exit 1 ;
153
fi
154

    
155
## uncomment next line to enable full debug
156
#DEBUGOPTIONS="-log -clean -debug -console -noexit"
157

    
158
SWT_GTK3=0 UBUNTU_MENUPROXY=0 exec "${TXMINSTALL}/TXM" -consoleLog "$@" -run --launcher.ini "$DOTTXMHOME/TXM.ini" $DEBUGOPTIONS -configuration "$DOTTXMHOME/configuration" -user "$DOTTXMHOME/user" -install "$TXMINSTALL"