Statistics
| Revision:

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

History | View | Annotate | Download (5.8 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
echo "TXM: Preparing redirections in $HOME/TXM_PostInstallOutputLogs.txt and $HOME/TXM_PostInstallErrorLogs.txt files."
5

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

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

    
11
TXMINSTALL="/usr/lib/TXM${VERSION}"
12
TXMHOME="$HOME/TXM${VERSION}"
13
DOTTXMHOME="$TXMHOME/.txm"
14

    
15
(
16
echo "TXM: $HOME is '$HOME'"
17

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

    
24
echo "TXM: Creating all necessary directories."
25

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

    
36

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

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

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

    
55
STAMP=`stat -c %Y "$TXMINSTALL/STAMP"`
56

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

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

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

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

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

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

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

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

    
139
    echo "TXM: creating the $DOTTXMHOME/$STAMP flag file."
140
    touch "$DOTTXMHOME/$STAMP"
141

    
142
    if [ $? != 0 ]; then
143
        zenity --info --text="TXMLaunch: Can't launch TXM: failed to create the $DOTTXMHOME/$STAMP install STAMP file$LOGFILESMSG"
144
		echo "TXM: Can't launch TXM: failed to create the $DOTTXMHOME/$STAMP install STAMP file$LOGFILESMSG"
145
        exit 1
146
    fi
147
fi
148

    
149
) 1>&3 2>&4
150

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

    
157
## uncomment next lien to enable full debug
158
#DEBUGOPTIONS="-log -consolelog -clean -debug -console -noexit"
159

    
160
SWT_GTK3=0 UBUNTU_MENUPROXY=0 exec "${TXMINSTALL}/TXM" "$@" -run --launcher.ini "$DOTTXMHOME/TXM.ini" $DEBUGOPTIONS -data "$TXMHOME/corpora" -user "$DOTTXMHOME/user" -install "$TXMINSTALL"