diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index e4dda746e3..b892a4b63c 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -32,6 +32,7 @@ import com.droiddeck.launcher.gpu.LsfgNative import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.runtime.DesktopCatalog import com.droiddeck.launcher.runtime.LinuxRuntimeInstaller +import com.droiddeck.launcher.runtime.DeckyManager import com.droiddeck.launcher.session.SessionService import com.droiddeck.launcher.ui.PackageRow import com.droiddeck.launcher.session.OfflineMode @@ -94,6 +95,13 @@ class MainActivity : ComponentActivity() { private var steamDeckMode by mutableStateOf(false) private var showCredits by mutableStateOf(false) private var showProtons by mutableStateOf(false) + private var deckyInstalled by mutableStateOf(null) + private var deckyReleases by mutableStateOf>(emptyList()) + private var deckyChecking by mutableStateOf(false) + private var deckyStage by mutableStateOf(null) + private var deckyPercent by mutableIntStateOf(-1) + private var deckySupervisor by mutableStateOf(false) + private var deckyReleaseRequest = 0 private var showMapping by mutableStateOf(false) private var controllerSettings by mutableStateOf(null) private var catalog by mutableStateOf?>(null) @@ -472,6 +480,9 @@ class MainActivity : ComponentActivity() { refreshHomeAppState() refreshSecondScreenDisplays() refresh() + deckyInstalled = DeckyManager.installed(this) + DeckyManager.syncCefMarker(this) + deckySupervisor = DeckyManager.supervisorEnabled(this) // Added games' art (a store lookup for what the folders lack) starts here, not only when // the cog opens. refreshAddedGames() @@ -542,6 +553,37 @@ class MainActivity : ComponentActivity() { refreshProtons() } + private fun refreshDecky() { + val request = ++deckyReleaseRequest + deckyChecking = true + Thread({ + val channels = runCatching { DeckyManager.releaseChannels(this) } + .getOrElse { DeckyManager.ReleaseChannels(emptyList(), emptyList()) } + ui.post { + if (request == deckyReleaseRequest) { + // Use the newest compatible stable build, or the newest compatible + // prerelease when the fork has not published a stable ARM64 asset. + deckyReleases = channels.stable.ifEmpty { channels.prerelease } + deckyChecking = false + } + } + }, "decky-releases").start() + } + + private fun installDecky(release: DeckyManager.Release) { + if (deckyStage != null || SessionState.running) return + deckyStage = "Starting…"; deckyPercent = -1 + Thread({ + val problem = runCatching { + DeckyManager.install(this, release) { label, value -> ui.post { deckyStage = label; deckyPercent = value } } + }.getOrElse { error -> "Decky install failed: ${error.message ?: error.javaClass.simpleName}" } + ui.post { + deckyStage = null; deckyPercent = -1; deckyInstalled = DeckyManager.installed(this) + if (problem != null) android.widget.Toast.makeText(this, problem, android.widget.Toast.LENGTH_LONG).show() + } + }, "install-decky").start() + } + private fun refreshController() { controllerSettings = ControllerPrefs.read(this) } @@ -679,6 +721,10 @@ class MainActivity : ComponentActivity() { addedGamesArt = addedGamesArt, linuxDownloads = linuxDownloads, androidDownloads = androidDownloads, releaseStatus = releaseStatus, releaseChecking = releaseChecking, canRestoreBundled = canRestoreBundled, + deckyInstalled = if (mode == SessionService.MODE_STEAM) deckyInstalled else null, + deckyLatestRelease = if (mode == SessionService.MODE_STEAM) deckyReleases.firstOrNull() else null, + deckyChecking = deckyChecking, deckyStage = deckyStage, deckyPercent = deckyPercent, + deckyEnabled = deckySupervisor, deckySessionRunning = SessionState.running, ), ModeSettingsActions( onResolution = { cap -> SessionPrefs.setResolutionCap(this, mode, cap); resolutionCap = cap }, @@ -728,6 +774,14 @@ class MainActivity : ComponentActivity() { pendingAddedGame = folder pickAddedGameExe.launch(InAppFilePicker.buildIntent(this, listOf("exe"), "Choose the game's .exe", folder)) }, + onDeckyInstall = { release -> installDecky(release) }, + onDeckyCheck = { refreshDecky() }, + onDeckyEnabled = { enabled -> DeckyManager.setSupervisorEnabled(this, enabled); deckySupervisor = enabled }, + onDeckyUninstall = { + DeckyManager.uninstall(this, wipeData = false) + deckyInstalled = null + deckySupervisor = false + }, onDismiss = { settingsMode = null }, ), ) @@ -805,6 +859,11 @@ class MainActivity : ComponentActivity() { renderer = SessionPrefs.desktopRenderer(this) gameStorage = SessionPrefs.gameStorage(this) storageOptions = GameStorage.options(this).map { it.label to it.path } + if (mode == SessionService.MODE_STEAM) { + deckyInstalled = DeckyManager.installed(this) + deckySupervisor = DeckyManager.supervisorEnabled(this) + refreshDecky() + } settingsMode = mode } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/DeckyManager.kt b/app/src/main/java/com/droiddeck/launcher/runtime/DeckyManager.kt new file mode 100644 index 0000000000..cef72df493 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/runtime/DeckyManager.kt @@ -0,0 +1,168 @@ +package com.droiddeck.launcher.runtime + +import android.content.Context +import android.util.Log +import com.droiddeck.launcher.core.Downloader +import com.droiddeck.launcher.session.SessionState +import java.io.File +import java.io.FileInputStream +import java.security.MessageDigest +import org.json.JSONArray + +/** Optional Decky Loader installation for the ARM64 Linux guest. */ +object DeckyManager { + private const val TAG = "DeckyManager" + const val REPOSITORY = "Droid-Deck/decky-loader" + private const val RELEASES = "https://api.github.com/repos/$REPOSITORY/releases?per_page=30" + private const val PATH = "root/homebrew/services/PluginLoader" + private const val VERSION = "root/homebrew/services/.droiddeck-decky-version" + private const val CEF_REMOTE_DEBUG_MARKER = "root/.local/share/Steam/.cef-enable-remote-debugging" + + data class Release(val tag: String, val prerelease: Boolean, val asset: String, val url: String, val digest: String?, val shaUrl: String?, val size: Long, val machine: Int) + data class ReleaseChannels(val stable: List, val prerelease: List) + + fun installed(context: Context): String? { + val loader = loader(context) + if (!loader.isFile || !loader.canExecute()) return null + return File(LinuxRuntime.rootDir(context), VERSION).takeIf { it.isFile }?.readText()?.trim()?.takeIf { it.isNotEmpty() } ?: "Installed" + } + + fun loader(context: Context) = File(LinuxRuntime.rootDir(context), PATH) + fun supervisorEnabled(context: Context) = File(LinuxRuntime.rootDir(context), "root/.droiddeck-decky-enabled").isFile + + /** Remove the legacy install-time debugger marker unless the user opted into Decky. */ + fun syncCefMarker(context: Context) { + val marker = File(LinuxRuntime.rootDir(context), CEF_REMOTE_DEBUG_MARKER) + if (!supervisorEnabled(context)) { + marker.delete() + return + } + runCatching { + marker.parentFile?.mkdirs() + marker.createNewFile() + } + } + + fun setSupervisorEnabled(context: Context, enabled: Boolean) { + val marker = File(LinuxRuntime.rootDir(context), "root/.droiddeck-decky-enabled") + val cefMarker = File(LinuxRuntime.rootDir(context), CEF_REMOTE_DEBUG_MARKER) + if (enabled) { + marker.parentFile?.mkdirs() + marker.writeText("enabled\n") + cefMarker.parentFile?.mkdirs() + cefMarker.createNewFile() + } else { + marker.delete() + cefMarker.delete() + } + } + + fun releases(context: Context, prerelease: Boolean): List { + val channels = releaseChannels(context) + return if (prerelease) channels.prerelease else channels.stable + } + + fun releaseChannels(context: Context): ReleaseChannels { + val body = Downloader.downloadString(RELEASES) ?: return ReleaseChannels(emptyList(), emptyList()) + return try { + val array = JSONArray(body) + val stable = mutableListOf() + val prerelease = mutableListOf() + for (i in 0 until array.length()) { + val release = array.getJSONObject(i) + if (release.optBoolean("draft", false)) continue + val isPrerelease = release.optBoolean("prerelease", false) + val assets = release.optJSONArray("assets") ?: continue + val rows = (0 until assets.length()).map { assets.getJSONObject(it) } + val arm = rows.firstOrNull { it.optString("name") == "PluginLoader-arm64" } + val guest = LinuxRuntime.rootDir(context) + val fexReady = File(guest, "usr/share/guestos/fex-mesa").isDirectory && File(guest, "usr/bin/FEX").canExecute() + val binary = arm ?: if (fexReady) rows.firstOrNull { it.optString("name") == "PluginLoader" } else null + val name = binary?.optString("name") ?: continue + val url = binary.optString("browser_download_url").takeIf { it.startsWith("https://") } ?: continue + val checksum = rows.firstOrNull { + val n = it.optString("name") + (n == "$name.sha256" || n == "$name.sha256sum" || n == "$name.sha256.txt") && it.optString("browser_download_url").startsWith("https://") + }?.optString("browser_download_url")?.takeIf { it.startsWith("https://") } + val digest = binary.optString("digest").takeIf { it.matches(Regex("(?i)sha256:[0-9a-f]{64}")) } + if (digest == null && checksum == null) continue + val size = binary.optLong("size", 0) + if (size <= 0) continue + val row = Release(release.optString("tag_name", "unknown"), isPrerelease, name, url, digest, checksum, size, if (name == "PluginLoader-arm64") 183 else 62) + (if (isPrerelease) prerelease else stable).add(row) + } + ReleaseChannels(stable, prerelease) + } catch (e: Exception) { Log.w(TAG, "release metadata", e); ReleaseChannels(emptyList(), emptyList()) } + } + + /** Downloads to a sibling temp file and atomically renames only after size, digest and ELF checks. */ + fun install(context: Context, release: Release, progress: (String, Int) -> Unit): String? { + if (SessionState.running) return "Stop the active session before installing Decky Loader" + val target = loader(context) + target.parentFile?.mkdirs() + val temp = File(target.parentFile, "PluginLoader.download") + val ok = Downloader.downloadFile(release.url, temp, false) { f -> progress("Downloading ${release.tag}", if (f < 0) -1 else (f * 100).toInt().coerceIn(0, 100)) } + if (!ok) { temp.delete(); return "Decky Loader download failed" } + if (temp.length() != release.size) { temp.delete(); return "Decky Loader size did not match the release metadata" } + val expected = release.digest?.substringAfter(':') ?: release.shaUrl?.let { checksumUrl -> + val checksumBody = Downloader.downloadString(checksumUrl) ?: run { temp.delete(); return "Could not download the release checksum" } + Regex("(?i)\\b[0-9a-f]{64}\\b").find(checksumBody)?.value + } ?: run { temp.delete(); return "Release checksum is missing" } + if (!expected.matches(Regex("(?i)[0-9a-f]{64}"))) { temp.delete(); return "Release checksum is invalid" } + if (!expected.equals(sha256(temp), true)) { temp.delete(); return "Decky Loader checksum mismatch" } + if (!validElf(temp, release.machine)) { temp.delete(); return "Release asset is not a compatible 64-bit Linux executable" } + if (SessionState.running) { temp.delete(); return "A session started during the download; stop it before installing Decky Loader" } + if (!temp.setExecutable(true, false)) { temp.delete(); return "Could not mark PluginLoader executable" } + // Decky needs Steam's local CEF debugger only when its session supervisor is enabled. + val cefMarker = File(LinuxRuntime.rootDir(context), CEF_REMOTE_DEBUG_MARKER) + val cefReady = !supervisorEnabled(context) || cefMarker.isFile || runCatching { + cefMarker.parentFile?.mkdirs() + cefMarker.createNewFile() || cefMarker.isFile + }.getOrDefault(false) + if (!cefReady) { temp.delete(); return "Could not enable Steam CEF remote debugging" } + val staged = File(target.parentFile, "PluginLoader.new") + staged.delete() + if (!temp.renameTo(staged)) { temp.delete(); return "Could not stage PluginLoader" } + val old = File(target.parentFile, "PluginLoader.old") + old.delete() + if (target.exists() && !target.renameTo(old)) { staged.delete(); return "Could not preserve the existing PluginLoader" } + if (!staged.renameTo(target)) { + if (old.exists()) old.renameTo(target) + staged.delete() + return "Could not activate the new PluginLoader" + } + old.delete() + File(target.parentFile, ".droiddeck-decky-version").writeText(release.tag + "\n") + File(target.parentFile, ".droiddeck-decky-arch").writeText(if (release.machine == 183) "arm64\n" else "x86_64\n") + if (!supervisorEnabled(context)) cefMarker.delete() + return null + } + + fun uninstall(context: Context, wipeData: Boolean) { + val root = LinuxRuntime.rootDir(context) + setSupervisorEnabled(context, false) + File(root, PATH).delete() + File(root, VERSION).delete() + File(root, "root/homebrew/services/.droiddeck-decky-arch").delete() + File(root, CEF_REMOTE_DEBUG_MARKER).delete() + if (wipeData) File(root, "root/homebrew").deleteRecursively() + } + + private fun sha256(file: File): String { + val digest = MessageDigest.getInstance("SHA-256") + FileInputStream(file).buffered().use { input -> + val buffer = ByteArray(1024 * 1024) + while (true) { val n = input.read(buffer); if (n < 0) break; digest.update(buffer, 0, n) } + } + return digest.digest().joinToString("") { "%02x".format(it.toInt() and 255) } + } + + private fun validElf(file: File, machine: Int): Boolean = runCatching { + file.inputStream().use { input -> + val h = ByteArray(20) + if (input.read(h) != h.size) return false + h[0] == 0x7f.toByte() && h[1] == 'E'.code.toByte() && h[2] == 'L'.code.toByte() && h[3] == 'F'.code.toByte() && + h[4] == 2.toByte() && h[5] == 1.toByte() && (h[18].toInt() and 255) + ((h[19].toInt() and 255) shl 8) == machine + } + }.getOrDefault(false) +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt index 9c964a0f5b..b0508b9c72 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt @@ -1,10 +1,16 @@ package com.droiddeck.launcher.ui import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.size +import androidx.compose.material3.AlertDialog import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Switch import androidx.compose.material3.Text +import androidx.compose.material3.LinearProgressIndicator +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -15,6 +21,7 @@ import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.droiddeck.launcher.core.FexPreset +import com.droiddeck.launcher.runtime.DeckyManager import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SessionService @@ -70,6 +77,14 @@ class ModeSettings( val releaseChecking: Boolean = false, /** A bundled display driver was deleted: the page offers to restore it. */ val canRestoreBundled: Boolean = false, + /** Steam only: Decky Loader is managed from the Steam session settings. */ + val deckyInstalled: String? = null, + val deckyLatestRelease: DeckyManager.Release? = null, + val deckyChecking: Boolean = false, + val deckyStage: String? = null, + val deckyPercent: Int = -1, + val deckyEnabled: Boolean = false, + val deckySessionRunning: Boolean = false, ) /** One added game as the settings page shows it: its folder, the chosen .exe, the other .exe files it could be. */ @@ -109,6 +124,10 @@ class ModeSettingsActions( val onAddedGamesArt: (Boolean) -> Unit = {}, val onAddedGameExe: (folderPath: String, path: String) -> Unit = { _, _ -> }, val onPickAddedGameExe: (folderPath: String) -> Unit = {}, + val onDeckyInstall: (DeckyManager.Release) -> Unit = {}, + val onDeckyCheck: () -> Unit = {}, + val onDeckyEnabled: (Boolean) -> Unit = {}, + val onDeckyUninstall: () -> Unit = {}, val onDismiss: () -> Unit, ) @@ -116,6 +135,7 @@ class ModeSettingsActions( fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { val steam = s.mode == SessionService.MODE_STEAM val host = rememberMenuHost() + var confirmDeckyRemoval by remember { mutableStateOf(false) } // The two driver lists open as full pages over this one ("rt" = runtime, "panel" = display). // Coming back restores this page as it was left: the same scroll position, and controller focus // on the driver box that opened the page. @@ -253,6 +273,58 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { onPick = a.onSuspendPolicy, ) } + if (steam) SettingsGroup("Decky") { + val updateAvailable = s.deckyInstalled != null && s.deckyLatestRelease != null && + s.deckyInstalled != s.deckyLatestRelease.tag + val status = when { + s.deckyStage != null -> s.deckyStage + s.deckyChecking -> "Checking compatible releases…" + s.deckyInstalled == null && s.deckyLatestRelease != null -> "Ready to install ${s.deckyLatestRelease.tag}." + s.deckyInstalled == null -> "No compatible build found. Check again later." + s.deckyLatestRelease == null -> "Installed · ${s.deckyInstalled}" + updateAvailable -> "Update available · ${s.deckyLatestRelease.tag}" + else -> "Up to date · ${s.deckyInstalled}" + } + SettingsRow("Loader", status) { + val action = when { + s.deckyStage != null -> "Working…" + s.deckyChecking -> "Checking…" + s.deckyInstalled == null && s.deckyLatestRelease != null -> "Install latest" + s.deckyInstalled != null && updateAvailable -> "Update" + else -> "Check" + } + Row(horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(6.dp)) { + SecondaryButton( + action, + enabled = s.deckyStage == null && !s.deckyChecking && !s.deckySessionRunning, + ) { + if (s.deckyLatestRelease == null || (s.deckyInstalled != null && !updateAvailable)) a.onDeckyCheck() + else s.deckyLatestRelease?.let(a.onDeckyInstall) + } + if (s.deckyInstalled != null) SecondaryButton( + "Uninstall", + enabled = s.deckyStage == null && !s.deckySessionRunning, + ) { confirmDeckyRemoval = true } + } + } + if (s.deckyInstalled != null) SettingsRow( + "Decky", + if (s.deckyEnabled) "Starts with Steam. Other apps on this device may be able to control Steam while enabled." + else "Off. Decky stays off and Steam's remote debugging port stays closed.", + ) { + Switch( + checked = s.deckyEnabled, + onCheckedChange = a.onDeckyEnabled, + enabled = !s.deckySessionRunning && s.deckyStage == null, + ) + } + if (s.deckyStage != null && s.deckyPercent >= 0) { + LinearProgressIndicator( + progress = { s.deckyPercent / 100f }, + modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp), + ) + } + } if (steam && s.steamChannel != null) SettingsGroup("Client") { ChoiceRow( host, "channel", "Client branch", "The Steam client build the session forces. Applies at the next session start; the client may update itself once.", @@ -349,6 +421,15 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { ) } } + if (confirmDeckyRemoval) AlertDialog( + onDismissRequest = { confirmDeckyRemoval = false }, + title = { Text("Uninstall Decky Loader?") }, + text = { Text("Remove the loader and keep your plugins and settings.") }, + confirmButton = { + TextButton(onClick = { confirmDeckyRemoval = false; a.onDeckyUninstall() }) { Text("Uninstall") } + }, + dismissButton = { TextButton(onClick = { confirmDeckyRemoval = false }) { Text("Cancel") } }, + ) } /** The Resolution menu's "Custom…" entry. */ diff --git a/tools/linuxfs/overlay/usr/local/bin/bannerlator-session b/tools/linuxfs/overlay/usr/local/bin/bannerlator-session index c54bcecd3e..318e7a0edb 100755 --- a/tools/linuxfs/overlay/usr/local/bin/bannerlator-session +++ b/tools/linuxfs/overlay/usr/local/bin/bannerlator-session @@ -440,6 +440,42 @@ BUSCONF # falls through to the host, and the guest shell dies on libreadline before the game is reached. # FEX_ROOTFS names it outright and is read whatever the config situation. [ -d /usr/share/guestos/fex-mesa ] && export FEX_ROOTFS=/usr/share/guestos/fex-mesa + # Decky is optional and session scoped: the app's marker opts in, and this supervisor is + # reaped with the client session. Native ARM64 runs directly. A legacy x86_64 asset is used + # only when its recorded architecture and this guest's existing FEX installation agree. + decky_loader=$HOME/homebrew/services/PluginLoader + if [ -f "$HOME/.droiddeck-decky-enabled" ] && [ -x "$decky_loader" ]; then + decky_arch=$(cat "$HOME/homebrew/services/.droiddeck-decky-arch" 2>/dev/null || echo unknown) + if [ "$decky_arch" = arm64 ] || { [ "$decky_arch" = x86_64 ] && [ -x /usr/bin/FEX ] && [ -n "${FEX_ROOTFS:-}" ]; }; then + ( + decky_child= + decky_stop() { [ -z "$decky_child" ] || kill "$decky_child" 2>/dev/null; [ -z "$decky_child" ] || wait "$decky_child" 2>/dev/null; exit 0; } + trap decky_stop TERM INT HUP + decky_exits=0 + while :; do + if [ "$decky_arch" = x86_64 ]; then /usr/bin/FEX "$decky_loader" >>"$HOME/homebrew/services/PluginLoader.log" 2>&1 & + else "$decky_loader" >>"$HOME/homebrew/services/PluginLoader.log" 2>&1 & + fi + decky_child=$! + decky_status=0 + wait "$decky_child" || decky_status=$? + decky_child= + decky_exits=$((decky_exits + 1)) + if [ "$decky_exits" -ge 5 ]; then + echo "== Decky: stopped after $decky_exits loader exits (last status $decky_status)" + break + fi + decky_delay=$((decky_exits * 3)) + echo "== Decky: loader exited with status $decky_status; restart $((decky_exits + 1))/5 in ${decky_delay}s" + sleep "$decky_delay" + done + ) & + decky_supervisor=$! + echo "== Decky: session supervisor started ($decky_arch)" + else + echo "== Decky: installed loader architecture is unsupported by this guest; not starting" + fi + fi # The client exits 42 when it has updated itself and wants a fresh start (steam.sh does this). # BL_STEAM_UI=desktop = the client's desktop UI (a window, the library as a list), which the # desktop's launchers ask for; gamescope shows one window at a time and the game takes over. @@ -521,10 +557,20 @@ BUSCONF # script's parent, so reap_orphans - right under gamescope, where everything is the client's - # is not for here. The helpers this run started (the cores and redistributables beats, the # system bus and the NetworkManager stand-in) go with the client instead. + if [ -n "${decky_supervisor:-}" ]; then + kill "$decky_supervisor" 2>/dev/null || true + wait "$decky_supervisor" 2>/dev/null || true + echo "== Decky: session supervisor stopped" + fi _bl_jobs=$(jobs -p) [ -n "$_bl_jobs" ] && kill $_bl_jobs 2>/dev/null echo "== steam: the client on the desktop has exited" else + if [ -n "${decky_supervisor:-}" ]; then + kill "$decky_supervisor" 2>/dev/null || true + wait "$decky_supervisor" 2>/dev/null || true + echo "== Decky: session supervisor stopped" + fi reap_orphans fi exit "$rc"