Statistics
| Revision:

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

History | View | Annotate | Download (5.5 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

    
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
TXMINSTALL="/usr/lib/TXM${VERSION}"
13
TXMHOME="$HOME/TXM${VERSION}"
14
DOTTXMHOME="$TXMHOME/.txm"
15

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

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

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

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

    
37

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

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

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

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

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

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

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

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

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

    
90
	echo "TXM: Installing up to date TXM directories."
91
	rm -rf "$DOTTXMHOME"
92
	if [ -d "$DOTTXMHOME" ]; then
93
	    zenity --info --text="TXM: Failed to remove $DOTTXMHOME directory$LOGFILESMSG"
94
	    echo "TXM: Failed to remove $DOTTXMHOME directory$LOGFILESMSG"
95
	    exit 1 ;
96
	fi
97

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

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

    
132
    echo "TXM: creating the $DOTTXMHOME/$STAMP flag file."
133
    touch "$DOTTXMHOME/$STAMP"
134

    
135
    if [ $? != 0 ]; then
136
        zenity --info --text="TXMLaunch: Can't launch TXM: failed to create the $DOTTXMHOME/$STAMP install STAMP file$LOGFILESMSG"
137
		echo "TXM: Can't launch TXM: failed to create the $DOTTXMHOME/$STAMP install STAMP file$LOGFILESMSG"
138
        exit 1
139
    fi
140
fi
141

    
142
) 1>&3 2>&4
143

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

    
150
## uncomment next lien to enable full debug
151
#DEBUGOPTIONS="-log -consolelog -clean -debug -console -noexit"
152

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