summarylogtreecommitdiffstats
path: root/xencelabs1.3.0-12.install
blob: c1c7614e0c08a6738610aa541a3e70d640c381ff (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
pre_install() {


	AppName=xencelabs
	AppDir=xencelabs

	#some operator before deb install
	echo "try to close driver if it is running"
	if [ -f "/var/lib/dpkg/lock" ]; then
		sudo rm /var/lib/dpkg/lock
	fi
	if [ -f "/var/lib/dpkg/lock-frontend" ]; then
		sudo rm /var/lib/dpkg/lock-frontend
	fi

	pid=`ps -e|grep $AppName`
	AppName=xencelabs
	appScript=$AppName".sh"
	if [ -n "$pid" ]; then
		echo $pid
		arr=()
		while read -r line; do
		   arr+=("$line")
		done <<< "$pid"
		for val in "${arr[@]}";
		do
			appid=`echo $val | awk '{print $1}'`
		   	name=`echo $val | awk '{print $4}'`
		   	echo "ID:"$appid 
			echo "Name:"$name
			if [ "$name" = "$appRunScript" ]; then
				echo "close $appRunScript"
				kill -15 $appid
			elif [ "$name" = "$AppName" ]; then
				echo "close $AppName"
				kill -15 $appid
			fi
		done
	fi

	# try to close driver if it exist
	pid=`ps -e|grep $AppName|awk '{print $1}'`
	if [ -n "$pid" ]; then
		echo "close xencelabs"
		kill -15 $pid
	fi

}

post_install() {

	#some operator after deb installed

	userinfo=`who`
	user=`who | awk  '{print $1}'|head -1`
	echo $user

	AppName=xencelabs
	appPath=/usr/lib/$AppName
	# change permission
	if [ -f /usr/lib/$AppName/start.sh ]; then
		echo "add shell permission"
		chmod +x $appPath/start.sh
	fi

	if [ -f /usr/lib/$AppName/$AppName ]; then
		echo "add exe permission"
		chmod +x $appPath/$AppName
	fi


	# Copy file to app's data path
	langDirName=language
	picDirName=picture
	appDir=/home/$user/.local/share
	dataPath=$appDir/$AppName
	languageDir=$dataPath/$langDirName
	picDir=$dataPath/$picDirName
	echo "create user data dir"
	if [ ! -d $appDir ];then
		echo `mkdir $appDir`
	fi
	if [ ! -d $dataPath ];then
		echo `mkdir $dataPath`
	fi

	chmod +0777 $appDir
	chmod +0777 $dataPath

	confDir=config
	confName=config.xml
	templateName=Template.xml


	echo "copy config"
	if [ -f $appPath/$confDir/$confName ];then
		echo `cp $appPath/$confDir/$confName $dataPath/$confName`
		chmod 0666 $dataPath/$confName
	fi
	chmod +0666 /usr/lib/xencelabs/config/linuxConfig

	echo "copy template config"
	if [ -f $appPath/$confDir/$templateName ];then
		echo `cp $appPath/$confDir/$templateName $dataPath/$templateName`
		chmod 0666 $dataPath/$templateName
	fi

	echo "copy banner"
	echo `cp -rf $appPath/$confDir/$picDirName $dataPath`
	chmod +0777 $picDir
	chmod +0666 $picDir/banner.png
	chmod +0666 $picDir/banner2.png

	if [ -d $appPath/$confDir ];then
		echo "copy lang"
		echo `cp -rf $appPath/$confDir/$langDirName $dataPath`
		chmod +0777 $languageDir
		chmod +0666 $languageDir/ChineseSimplified.ini
		chmod +0666 $languageDir/ChineseTraditional.ini
		chmod +0666 $languageDir/English.ini
		chmod +0666 $languageDir/French.ini
		chmod +0666 $languageDir/German.ini
		chmod +0666 $languageDir/Italian.ini
		chmod +0666 $languageDir/Japanese.ini
		chmod +0666 $languageDir/Korean.ini
		chmod +0666 $languageDir/Polish.ini
		chmod +0666 $languageDir/Russian.ini
		chmod +0666 $languageDir/Spanish.ini
	fi

	#change temp file permition
	echo "change tmp file permition"
	localfile="/tmp/qtsingleapp-Xencel-fb8d-lockfile"
	touch $localfile
	sudo chmod +0777 /tmp/qtsingleapp-Xencel-fb8d-lockfile

	echo "The installation is successful. If this is your first installation, restart your computer please"

}

pre_upgrade() {
	pre_install
}

post_upgrade() {
	post_install
}

pre_remove() {
	echo "==========================================================="
	AppName=xencelabs
	appRunScript=start.sh

	#some operator before uninstall
	pid=`ps -e|grep $AppName`

	if [ -n "$pid" ]; then
		echo $pid
		arr=()
		while read -r line; do
		   arr+=("$line")
		done <<< "$pid"
		for val in "${arr[@]}";
		do
			appid=`echo $val | awk '{print $1}'`
		   	name=`echo $val | awk '{print $4}'`
		   	echo "ID:"$appid 
			echo "Name:"$name

			if [ "$name" = "$appRunScript" ]; then
				echo "close $appRunScript"
				kill -15 $appid
			elif [ "$name" = "$AppName" ]; then
				echo "close $AppName"
				kill -15 $appid
			fi
		done
	fi

	pid=`ps -e|grep $AppName|awk '{print $1}'`
	if [ -n "$pid" ]; then
		echo "close xencelabs"
		kill -15 $pid
	fi

	AppName=xencelabs
	AppDir=xencelabs

	#some operator after deb uninstalled
	if [ -f "/usr/share/applications/$AppName.desktop" ]; then
		rm "/usr/share/applications/$AppName.desktop"
	fi

	if [ -f "/usr/share/icons/$AppName.png" ]; then
		rm "/usr/share/icons/$AppName.png"
	fi

	if [ -d "/usr/lib/$AppDir" ];then
		rm -rf "/usr/lib/$AppDir"
	fi

	userinfo=`who`
	user=`who | awk  '{print $1}'|head -1`
	echo $user

	dataPath=/home/$user/.local/share/$AppDir
	if [ -d $dataPath ];then
		echo `rm -rf $dataPath`
	fi

	echo "The uninstallation is successful."


}

post_remove() {
	echo "remove lockfile"
	sudo rm /tmp/qtsingleapp-Xencel-fb8d-lockfile


}

post_install() {
  echo "--------------------------------------------------------------------------------"
  echo "WARNING: Make sure you create the folder ~/.local/share/xencelabs/"
  echo "WARNING: and copy the contents of /usr/lib/xencelabs/config/ into it."
  echo "WARNING: xencelabs will not work unless you do this."
  echo "--------------------------------------------------------------------------------"
}

post_upgrade() {
  post_install
}