Skip to content

Commit 577b2f0

Browse files
committed
All files are moved to the environment directory
1 parent c94f12f commit 577b2f0

9 files changed

Lines changed: 29 additions & 83 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,12 @@ Updated list packages of base system installation
416416

417417
2.1.1
418418
Добавлена поддержка Fedora 28 (закончена поддержка 27 и более ранних)
419+
Улучшена работа веб-терминала
419420
Исправлена поддержка Arch Linux i686 (http://mirror.archlinux32.org)
420421
Исправлена проблема с начальной установкой Arch Linux (тикет #986)
421422
Исправлена проблема с установкой CentOS (тикет #972)
422423
Исправлена проблема с NSS и systemd (тикет #971)
423424
Исправлена проблема с unchroot am
424-
Улучшена работа веб-терминала
425425

426426
2.1.0
427427
Добавлена поддержка Ubuntu 18.04 LTS (bionic)

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
applicationId 'ru.meefik.linuxdeploy'
99
minSdkVersion 14
1010
targetSdkVersion 28
11-
versionCode 240
11+
versionCode 241
1212
versionName "2.1.1"
1313
}
1414
buildTypes {

app/src/main/assets/bin/all/websocket.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/ru.meefik.linuxdeploy/bin/sh
1+
#!/data/data/ru.meefik.linuxdeploy/env/bin/sh
22
# websocket.sh
33
# (C) 2016-2018 Anton Skshidlevsky <meefik@gmail.com>, MIT
44
# The cross platform WebSocket implementation for SH.

app/src/main/assets/web/cgi-bin/resize

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/ru.meefik.linuxdeploy/bin/sh
1+
#!/data/data/ru.meefik.linuxdeploy/env/bin/sh
22

33
echo "Content-type: text/html"
44
echo ""

app/src/main/assets/web/cgi-bin/sync

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/ru.meefik.linuxdeploy/bin/sh
1+
#!/data/data/ru.meefik.linuxdeploy/env/bin/sh
22

33
echo 'Content-Type: application/octet-stream'
44
echo 'Content-Transfer-Encoding: binary'

app/src/main/assets/web/cgi-bin/terminal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/ru.meefik.linuxdeploy/bin/sh
1+
#!/data/data/ru.meefik.linuxdeploy/env/bin/sh
22

33
echo "Content-type: text/html"
44
echo ""

app/src/main/java/ru/meefik/linuxdeploy/EnvUtils.java

Lines changed: 13 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private static boolean isRooted() {
200200
*/
201201
private static boolean setVersion(Context c) {
202202
boolean result = false;
203-
String f = PrefStore.getDataDir(c) + "/version";
203+
String f = PrefStore.getEnvDir(c) + "/version";
204204
BufferedWriter bw = null;
205205
try {
206206
bw = new BufferedWriter(new FileWriter(f));
@@ -221,7 +221,7 @@ private static boolean setVersion(Context c) {
221221
* @return true if success
222222
*/
223223
static boolean isLatestVersion(Context c) {
224-
File f = new File(PrefStore.getDataDir(c) + "/version");
224+
File f = new File(PrefStore.getEnvDir(c) + "/version");
225225
if (!f.exists()) return false;
226226
boolean result = false;
227227
BufferedReader br = null;
@@ -237,17 +237,6 @@ static boolean isLatestVersion(Context c) {
237237
return result;
238238
}
239239

240-
/**
241-
* Remove version file
242-
*
243-
* @param c context
244-
* @return true if success
245-
*/
246-
private static boolean resetVersion(Context c) {
247-
File f = new File(PrefStore.getDataDir(c) + "/version");
248-
return f.delete();
249-
}
250-
251240
/**
252241
* Make linuxdeploy script
253242
*
@@ -263,7 +252,6 @@ private static boolean makeScript(Context c) {
263252
bw.write("#!" + PrefStore.getShell(c) + "\n");
264253
bw.write("PATH=" + PrefStore.getPath(c) + ":$PATH\n");
265254
bw.write("ENV_DIR=\"" + PrefStore.getEnvDir(c) + "\"\n");
266-
bw.write("TEMP_DIR=\"" + PrefStore.getTmpDir(c) + "\"\n");
267255
bw.write(". \"${ENV_DIR}/cli.sh\"\n");
268256
result = true;
269257
} catch (IOException e) {
@@ -351,47 +339,34 @@ static boolean updateEnv(final Context c) {
351339
// stop services
352340
execServices(c, new String[]{"telnetd", "httpd"}, "stop");
353341

342+
// extract env assets
343+
if (!extractDir(c, PrefStore.getEnvDir(c), "env", "")) return false;
344+
354345
// extract bin assets
355346
if (!extractDir(c, PrefStore.getBinDir(c), "bin/all", "")) return false;
356347
if (!extractDir(c, PrefStore.getBinDir(c), "bin/" + PrefStore.getArch(), "")) return false;
357348

358-
// extract env assets
359-
if (!extractDir(c, PrefStore.getEnvDir(c), "env", "")) return false;
360-
361349
// extract web assets
362350
if (!extractDir(c, PrefStore.getWebDir(c), "web", "")) return false;
363351

364352
// make linuxdeploy script
365353
if (!makeScript(c)) return false;
366354

367-
// bin directory
355+
// set executable bin directory
368356
File binDir = new File(PrefStore.getBinDir(c));
369357
setPermissions(binDir, true);
370358

371-
// env directory
372-
File envDir = new File(PrefStore.getEnvDir(c));
373-
setPermissions(envDir, false);
374-
375-
// web directory
376-
File webDir = new File(PrefStore.getWebDir(c));
377-
setPermissions(webDir, false);
359+
// set executable cgi-bin directory
378360
File cgiDir = new File(PrefStore.getWebDir(c) + "/cgi-bin");
379361
setPermissions(cgiDir, true);
380362

381-
// etc directory
382-
File etcDir = new File(PrefStore.getEtcDir(c));
383-
etcDir.mkdirs();
384-
setPermissions(etcDir, false);
363+
// make config directory
364+
File configDir = new File(PrefStore.getConfigDir(c));
365+
configDir.mkdirs();
385366

386-
// tmp directory
367+
// make tmp directory
387368
File tmpDir = new File(PrefStore.getTmpDir(c));
388369
tmpDir.mkdirs();
389-
setPermissions(tmpDir, false);
390-
391-
// config directory
392-
File configDir = new File(PrefStore.getConfigDir(c));
393-
configDir.mkdirs();
394-
setPermissions(configDir, false);
395370

396371
// create .nomedia
397372
File noMedia = new File(PrefStore.getEnvDir(c) + "/.nomedia");
@@ -463,36 +438,17 @@ private static boolean removeSymlink(Context c) {
463438
* @return true if success
464439
*/
465440
static boolean removeEnv(Context c) {
466-
// remove version file
467-
resetVersion(c);
468-
469441
// stop services
470442
execServices(c, new String[]{"telnetd", "httpd"}, "stop");
471443

472444
// remove symlink
473445
File ldSymlink = new File("/system/bin/linuxdeploy");
474446
if (ldSymlink.exists()) removeSymlink(c);
475447

476-
// clean web directory
477-
File webDir = new File(PrefStore.getWebDir(c));
478-
cleanDirectory(webDir);
479-
480448
// clean env directory
481449
File envDir = new File(PrefStore.getEnvDir(c));
482450
cleanDirectory(envDir);
483451

484-
// clean etc directory
485-
File etcDir = new File(PrefStore.getEtcDir(c));
486-
cleanDirectory(etcDir);
487-
488-
// clean bin directory
489-
File binDir = new File(PrefStore.getBinDir(c));
490-
cleanDirectory(binDir);
491-
492-
// clean tmp directory
493-
File tmpDir = new File(PrefStore.getTmpDir(c));
494-
cleanDirectory(tmpDir);
495-
496452
return true;
497453
}
498454

@@ -600,7 +556,7 @@ static boolean httpd(Context c, String cmd) {
600556
params.add("export ENV_DIR=\"" + PrefStore.getEnvDir(c) + "\"");
601557
params.add("export HOME=\"" + PrefStore.getEnvDir(c) + "\"");
602558
params.add("cd " + PrefStore.getWebDir(c));
603-
params.add("httpd " + " -p " + PrefStore.getHttpPort(c) + " -c " + PrefStore.getEtcDir(c) + "/httpd.conf");
559+
params.add("httpd " + " -p " + PrefStore.getHttpPort(c) + " -c " + PrefStore.getEnvDir(c) + "/httpd.conf");
604560
}
605561
return params.size() > 0 && exec(c, "sh", params);
606562
}
@@ -615,7 +571,7 @@ private static boolean makeHttpdConf(Context c) {
615571
boolean result = false;
616572
BufferedWriter bw = null;
617573
try {
618-
String f = PrefStore.getEtcDir(c) + "/httpd.conf";
574+
String f = PrefStore.getEnvDir(c) + "/httpd.conf";
619575
bw = new BufferedWriter(new FileWriter(f));
620576
for (String part : PrefStore.getHttpConf(c).split(" ")) {
621577
bw.write(part + "\n");

app/src/main/java/ru/meefik/linuxdeploy/PrefStore.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static String getDataDir(Context c) {
6464
* Get environment directory
6565
*
6666
* @param c context
67-
* @return path, e.g. /data/data/package/files/env
67+
* @return path, e.g. /data/data/package/env
6868
*/
6969
static String getEnvDir(Context c) {
7070
String envDir = SETTINGS.get(c, "env_dir");
@@ -86,40 +86,30 @@ static String getConfigDir(Context c) {
8686
* Get bin directory
8787
*
8888
* @param c context
89-
* @return path, e.g. /data/data/package/bin
89+
* @return path, e.g. ${ENV_DIR}/bin
9090
*/
9191
static String getBinDir(Context c) {
92-
return getDataDir(c) + "/bin";
93-
}
94-
95-
/**
96-
* Get etc directory
97-
*
98-
* @param c context
99-
* @return path, e.g. /data/data/package/etc
100-
*/
101-
static String getEtcDir(Context c) {
102-
return getDataDir(c) + "/etc";
92+
return getEnvDir(c) + "/bin";
10393
}
10494

10595
/**
10696
* Get tmp directory
10797
*
10898
* @param c context
109-
* @return path, e.g. /data/data/package/tmp
99+
* @return path, e.g. ${ENV_DIR}/tmp
110100
*/
111101
static String getTmpDir(Context c) {
112-
return getDataDir(c) + "/tmp";
102+
return getEnvDir(c) + "/tmp";
113103
}
114104

115105
/**
116106
* Get web directory
117107
*
118108
* @param c context
119-
* @return path, e.g. /data/data/package/web
109+
* @return path, e.g. ${ENV_DIR}/web
120110
*/
121111
static String getWebDir(Context c) {
122-
return getDataDir(c) + "/web";
112+
return getEnvDir(c) + "/web";
123113
}
124114

125115
/**
@@ -421,10 +411,10 @@ static Boolean isStealth(Context c) {
421411
* Get PATH variable
422412
*
423413
* @param c context
424-
* @return path, e.g. /data/data/package/files/bin
414+
* @return path, e.g. ${ENV_DIR}/bin
425415
*/
426416
static String getPath(Context c) {
427-
String binDir = getDataDir(c) + "/bin";
417+
String binDir = getBinDir(c);
428418
String path = SETTINGS.get(c, "path");
429419
if (path.isEmpty()) path = binDir;
430420
else path = path + ":" + binDir;

0 commit comments

Comments
 (0)