Suppress stop/clean error reporting

This commit is contained in:
Mygod
2018-06-11 20:27:20 +08:00
parent f897368c61
commit 6b24697f12
2 changed files with 6 additions and 5 deletions

View File

@@ -29,7 +29,8 @@ class Routing(val upstream: String?, private val downstream: String, ownerAddres
"quiet while $IPTABLES -t nat -D POSTROUTING -j vpnhotspot_masquerade; do done", "quiet while $IPTABLES -t nat -D POSTROUTING -j vpnhotspot_masquerade; do done",
"$IPTABLES -t nat -F vpnhotspot_masquerade", "$IPTABLES -t nat -F vpnhotspot_masquerade",
"$IPTABLES -t nat -X vpnhotspot_masquerade", "$IPTABLES -t nat -X vpnhotspot_masquerade",
"quiet while ip rule del priority 17900; do done") "quiet while ip rule del priority 17900; do done",
report = false)
} }
class InterfaceNotFoundException : SocketException() { class InterfaceNotFoundException : SocketException() {
@@ -125,6 +126,6 @@ class Routing(val upstream: String?, private val downstream: String, ownerAddres
fun stop(): Boolean { fun stop(): Boolean {
if (!started) return true if (!started) return true
started = false started = false
return noisySu(stopScript) == true return noisySu(stopScript, false) == true
} }
} }

View File

@@ -45,7 +45,7 @@ fun loggerSu(command: String): String? {
} }
} }
fun noisySu(commands: Iterable<String>): Boolean? { fun noisySu(commands: Iterable<String>, report: Boolean = true): Boolean? {
var out = loggerSu("""function noisy() { "$@" || echo "$@" exited with $?; } var out = loggerSu("""function noisy() { "$@" || echo "$@" exited with $?; }
${commands.joinToString("\n") { if (it.startsWith("quiet ")) it.substring(6) else "noisy $it" }} ${commands.joinToString("\n") { if (it.startsWith("quiet ")) it.substring(6) else "noisy $it" }}
echo $NOISYSU_SUFFIX""") echo $NOISYSU_SUFFIX""")
@@ -53,8 +53,8 @@ echo $NOISYSU_SUFFIX""")
out = out?.removeSuffix(NOISYSU_SUFFIX) out = out?.removeSuffix(NOISYSU_SUFFIX)
if (!out.isNullOrBlank()) { if (!out.isNullOrBlank()) {
Crashlytics.log(Log.INFO, NOISYSU_TAG, out) Crashlytics.log(Log.INFO, NOISYSU_TAG, out)
Crashlytics.logException(SuFailure()) if (report) Crashlytics.logException(SuFailure())
} }
return result return result
} }
fun noisySu(vararg commands: String) = noisySu(commands.asIterable()) fun noisySu(vararg commands: String, report: Boolean = true) = noisySu(commands.asIterable(), report)