Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
8b8b0ef
modified: customize.sh
SCOS100 Oct 30, 2024
7862591
Merge branch 'main' of https://github.com/SCOS100/lhroot
SCOS100 Oct 30, 2024
717d07a
Merge pull request #2 from ONENAMED/main
SCOS100 Oct 30, 2024
7cd6c33
Create main.yml
SCOS100 Oct 30, 2024
f8d4650
Update main.yml
SCOS100 Oct 30, 2024
170d265
Update main.yml
SCOS100 Oct 30, 2024
b86027b
Update main.yml
SCOS100 Oct 30, 2024
1940f39
Update main.yml
SCOS100 Oct 30, 2024
09317a8
Update main.yml
SCOS100 Oct 30, 2024
485da0e
Update main.yml
SCOS100 Oct 30, 2024
40f27a4
Update main.yml
SCOS100 Oct 30, 2024
459ee21
Update main.yml
SCOS100 Oct 30, 2024
1d38a04
Update main.yml
SCOS100 Oct 30, 2024
6822c75
Update main.yml
SCOS100 Oct 30, 2024
5f83e12
Update main.yml
SCOS100 Oct 30, 2024
0ba5a8e
Update main.yml
SCOS100 Oct 30, 2024
a1927cc
Update main.yml
SCOS100 Oct 30, 2024
d691349
Update main.yml
SCOS100 Oct 30, 2024
63a686b
Update main.yml
SCOS100 Oct 30, 2024
e27ecbb
Update main.yml
SCOS100 Oct 30, 2024
32359dd
Update main.yml
SCOS100 Oct 30, 2024
ed85425
Update main.yml
SCOS100 Oct 30, 2024
6e68227
Create release.yml
SCOS100 Oct 30, 2024
1863d9e
Update release.yml
SCOS100 Oct 30, 2024
4c3a51d
Update release.yml
SCOS100 Oct 30, 2024
644dfdc
Update release.yml
SCOS100 Oct 30, 2024
5733034
Update release.yml
SCOS100 Oct 30, 2024
a5ce05b
Update release.yml
SCOS100 Oct 30, 2024
570cfff
Update mod-util.sh
SCOS100 Oct 30, 2024
d5559b4
modified: mod-util.sh
SCOS100 Oct 31, 2024
1a98b65
Update main.yml
SCOS100 Oct 31, 2024
cab6cf2
Update README.md
SCOS100 Oct 31, 2024
bff994e
modified: system/bin/lhroot
SCOS100 Oct 31, 2024
afab79a
Merge branch 'main' of https://github.com/SCOS100/lhroot
SCOS100 Oct 31, 2024
ca0a150
modified: lhroot
SCOS100 Oct 31, 2024
4e5cadc
modified: system/bin/bootlinux
SCOS100 Oct 31, 2024
27c0ac3
modified: lhroot
SCOS100 Oct 31, 2024
80df7b0
modified: killlinux
SCOS100 Oct 31, 2024
5abb7f0
Update README.md
SCOS100 Oct 31, 2024
8eadd9e
modified: system/bin/debootstrap
SCOS100 Nov 4, 2024
beec679
Merge branch 'main' of https://github.com/SCOS100/lhroot
SCOS100 Nov 4, 2024
2966ada
new file: system/bin/bash
SCOS100 Nov 4, 2024
02a6a4c
nano
SCOS100 Nov 9, 2024
461afa8
hellothere
SCOS100 Nov 9, 2024
57de734
hellothere1
SCOS100 Nov 9, 2024
8942ec3
hellothere1
SCOS100 Nov 9, 2024
075b9e1
hellothere1
SCOS100 Nov 9, 2024
3c12322
hellothere1
SCOS100 Nov 9, 2024
acf3064
hellothere1
SCOS100 Nov 10, 2024
a95e24c
hellothere1
SCOS100 Nov 10, 2024
37adc3a
yes
SCOS100 Nov 15, 2024
8a1960f
Fixed bug in lhroot
SCOS100 Nov 17, 2024
e8d3f0c
Fixed bug in lhroot and bootlinux_init
SCOS100 Nov 18, 2024
fb0629b
Added quick scripts for releases.
SCOS100 Nov 19, 2024
ad3c9cb
Fixed bug in lhroot.
SCOS100 Nov 19, 2024
4d87f79
modified: killlinux
SCOS100 Nov 23, 2024
0811ae6
YES, I've figured it out: to unmount dev we need `umount -l dev/`!
SCOS100 Nov 23, 2024
fb014a2
Redirected stderr.
SCOS100 Nov 23, 2024
814d5c5
Update README.md
SCOS100 Nov 30, 2024
6500b30
Update README.md
SCOS100 Nov 30, 2024
9c10b54
Update README.md
SCOS100 Nov 30, 2024
9cad026
Update README.md
SCOS100 Nov 30, 2024
9676f12
Fixed errors an other.
SCOS100 Dec 1, 2024
7931d64
Merge branch 'main' of https://github.com/SCOS100/lhroot
SCOS100 Dec 1, 2024
4357672
modified: system/bin/killlinux
SCOS100 Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release

on: push

defaults:
run:
shell: bash

jobs:
release:
runs-on: ubuntu-latest
name: Get a working Release.
outputs:
output_1: ${{ steps.gen_output.outputs.output_1 }}
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Create Zip
run: zip -r lhroot.zip ./*
- name: Upload Artifact
uses: actions/upload-artifact@v4.4.3
with:
name: lhroot Release
path: ./lhroot.zip

25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Upload To Release
on:
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: 'Download latest successful build artifact'
run: |
gh_last_success_run_id=$(gh run list -w $WORKFLOW --json conclusion,headBranch,databaseId --jq 'first(.[] | select(.conclusion | contains("success"))) | .databaseId')
[ -z "$gh_last_success_run_id" ] && echo "No successful run found" && exit 1 || true
gh run download $gh_last_success_run_id -n $ARTIFACT_NAME -D $OUTPUT_DIR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW: .github/workflows/main.yaml
ARTIFACT_NAME: lhroot Release
OUTPUT_DIR: .
- name: Upload to release
uses: JasonEtco/upload-to-release@master
with:
args: ./*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions .scripts/zip-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!$PATH/bash
if [ $(for i in $(ls $CWD); do if [ $i == zip-all ]; then echo yes; break; fi; done) == "yes" ]; then
version="$(cat ../module.prop | grep -w version | cut -d= -f2 -s)"
zip -0 -r "lhroot-${version}-release.zip" ../*
elif [ $(for i in $(ls $CWD); do if [ $i == module.prop ]; then echo yes; break; fi; done) == "yes" ]; then
version="$(cat module.prop | grep -w version | cut -d= -f2 -s)"
zip -0 -r "lhroot-${version}-release.zip" ./*
else
echo "[E] Did not detect either zip-all nor module.prop. Make sure you're running this in the lhroot repo."
fi
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,34 @@ Systemless Linux chroot installer and Linux chroot boot script - Modded by ***SC
- coreutils for make_image
- mke2fs for make_image
- This module
- Termux (For Debian)

![Manjaro-Linux-Android](https://i.ibb.co/gdpw8QG/lhroot.png)

## NOTICE
~~Due to many cases like [this](https://github.com/FerryAr/lhroot/issues/18) and [this](https://github.com/FerryAr/lhroot/issues/21). Please make sure ALL mountpoint on chroot folder is UNMOUNTED before removing chroot folder. I don't responsible for lost all data, phone bricking, etc. You can check this repository that all the code I wrote, doesn't intentionally remove your data or bricking your phone.~~ This is fixed, because `killlinux` is called after exiting. Use this module if you are familiar about Linux Enviroment. DWYOR!
~~Due to many cases like [this](https://github.com/FerryAr/lhroot/issues/18) and [this](https://github.com/FerryAr/lhroot/issues/21). Please make sure ALL mountpoint on chroot folder is UNMOUNTED before removing chroot folder. I don't responsible for lost all data, phone bricking, etc. You can check this repository that all the code I wrote, doesn't intentionally remove your data or bricking your phone.~~
This is fixed, because `killlinux` is called after exiting. Use this module if you are familiar about Linux Enviroment. DWYOR!

## Downloads

To download, look at the latest available artifact made by going to [this link.](https://github.com/SCOS100/lhroot/actions)

## Usage

*If you're running this on Termux, remember to install root-repo and tsu, and append `sudo` before each command.*

```console
lhroot
```

and follow the instructions
and follow the instructions.

##

### Warning before proceeding:
Due to a new feature, the `bootlinux` command now starts all /etc/init.d files. Because of this, remember to use `bootlinux_origin` if you have elogind, seatd, or SysVInit installed, or your phone will shutdown once exited.

##
After installation to boot into Linux Chroot use :

```console
Expand All @@ -40,7 +54,7 @@ To unmount bind directory use :
killlinux
```

***Note***: You don't need to do this anymore, after the exit command is supplied or KILL signal is executed.
***Note***: You don't need to do this anymore, after the exit command is executed.

To terminate specific instance, just pass chroot folder, e.g.

Expand Down Expand Up @@ -80,6 +94,9 @@ mount_image <path to img> <path to linux directory>

## TODO
- [ ] Built in Audio support
- [x] Add debootstrap to bins
- [ ] Add debootstrap for every distro
- [x] Auto-Config of resolv.conf and hosts

## Credits
- [mod-util](https://github.com/veez21/mod-util) by @veez21
Expand Down
6 changes: 6 additions & 0 deletions customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ set_perm $MODPATH/system/bin/lhroot 0 0 0777
set_perm $MODPATH/system/bin/bootlinux 0 0 0755
set_perm $MODPATH/mod-util.sh 0 0 0777
set_perm $MODPATH/system/bin/killlinux 0 0 0755
set_perm $MODPATH/system/bin/pkgdetails 0 0 0755
set_perm $MODPATH/system/bin/debootstrap 0 0 0755
set_perm $MODPATH/system/usr/share/debootstrap 0 9997 0770
set_perm $MODPATH/system/usr/share/debootstrap/functions 0 9997 0770
set_perm $MODPATH/system/usr/share/debootstrap/scripts 0 9997 0770
set_perm $MODPATH/system/usr/share/debootstrap/scripts/* 0 9997 0770
19 changes: 10 additions & 9 deletions mod-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
##########################################################################################

# Versions
MODUTILVER=v2.6
MODUTILVCODE=262
MODUTILVER=v2.6.1
MODUTILVCODE=261

# Check A/B slot
if [ -d /system_root ]; then
Expand Down Expand Up @@ -72,7 +72,6 @@ set_perm() {
chmod $4 $1 || return 1
(if [ -z $5 ]; then
case $1 in
*"/bin/"*) chcon 'u:object_r:system_file:s0' $1;;
*"system/vendor/app/"*) chcon 'u:object_r:vendor_app_file:s0' $1;;
*"system/vendor/etc/"*) chcon 'u:object_r:vendor_configs_file:s0' $1;;
*"system/vendor/overlay/"*) chcon 'u:object_r:vendor_overlay_file:s0' $1;;
Expand Down Expand Up @@ -177,12 +176,10 @@ div="${Bl}$(printf '%*s' "${character_no}" '' | tr " " "=")${N}"
# title_div [-c] <title>
# based on $div with <title>
title_div() {
set +x
[ "$1" == "-c" ] && local character_no=$2 && shift 2
[ -z "$1" ] && { local message=; no=0; } || { local message="$@ "; local no=$(echo "$@" | wc -c); }
[ $character_no -gt $no ] && local extdiv=$((character_no-no)) || { echo "Invalid!"; return; }
[ $character_no -gt $no ] && local extdiv=$(( ${character_no} - ${no} ))
echo "${W}$message${N}${Bl}$(printf '%*s' "$extdiv" '' | tr " " "=")${N}"
set -x 2>>$VERLOG
}

# set_file_prop <property> <value> <prop.file>
Expand All @@ -204,7 +201,7 @@ ProgressBar() {
# Determine Screen Size
if [[ "$COLUMNS" -le "57" ]]; then
local var1=2
local var2=20
local var2=20
else
local var1=4
local var2=40
Expand Down Expand Up @@ -241,15 +238,13 @@ printf "\r${@} [${_indicator}]"

# cmd & spinner <message>
e_spinner() {
set +x
PID=$!
h=0; anim='-\|/';
while [ -d /proc/$PID ]; do
h=$(((h+1)%4))
sleep 0.02
printf "\r${@} [${anim:$h:1}]"
done
set -x 2>>$VERLOG
}

# test_connection
Expand All @@ -266,6 +261,7 @@ test_connection() {
) && echo " - OK" || { echo " - Error"; false; }
}


# Log files will be uploaded to termbin.com
# Logs included: VERLOG LOG oldVERLOG oldLOG
upload_logs() {
Expand All @@ -276,11 +272,16 @@ upload_logs() {
[ -s $oldVERLOG ] && oldverUp=$(cat $oldVERLOG | nc termbin.com 9999) || oldverUp=none
[ -s $LOG ] && logUp=$(cat $LOG | nc termbin.com 9999) || logUp=none
[ -s $oldLOG ] && oldlogUp=$(cat $oldLOG | nc termbin.com 9999) || oldlogUp=none
[ -s $stdoutLOG ] && stdoutUp=$(cat $stdoutLOG | nc termbin.com 9999) || stdoutUp=none
[ -s $oldstdoutLOG ] && oldstdoutUp=$(cat $oldstdoutLOG | nc termbin.com 9999) || oldstdoutUp=none
echo -n "Link: "
echo "$MODEL ($DEVICE) API $API\n$ROM\n$ID\n
O_Verbose: $oldverUp
Verbose: $verUp

O_STDOUT: $oldstdoutUp
STDOUT: $stdoutUp

O_Log: $oldlogUp
Log: $logUp" | nc termbin.com 9999
} || echo "Busybox not found!"
Expand Down
2 changes: 1 addition & 1 deletion module.prop
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name=Linux Chroot Installer
version=v2.2.1M
versionCode=2
author=FerryAr - Mod by SCOS100
description=Systemless linux chroot installer and chroot boot script - Modded version.
description=Systemless Linux chroot Installer and chroot Boot Script.
20 changes: 20 additions & 0 deletions service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This script makes sure that debootstrap works as intended by linking /system/usr/ with a new directory called /usr/

mount -o rw,remount /

if [ -e /usr/ ]; then
if [ -e /system/usr/share/debootstrap/ ]; then
mount -w /system/usr/ /usr/
else
sleep 10
mount -w /system/usr/ /usr/
fi
else
mkdir /usr
if [ -e /system/usr/share/debootstrap/ ]; then
mount -w /system/usr/ /usr/
else
sleep 10
mount -w /system/usr/ /usr/
fi
fi
14 changes: 13 additions & 1 deletion system/bin/bootlinux
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
#!/system/bin/sh

exec 2>/dev/null

######### IMPORT BOOTLINUX ENVIRONMENT #########
SCRIPT_PATH=$(readlink -f $0)
. ${SCRIPT_PATH%/*}/bootlinux_env

######### STARTING run-parts #########
echo "Checking is there are files inside /etc/init.d to start."
if [ -e $mnt/etc/init.d/ ]; then
echo "Found executables, sleeping 3 seconds before starting."
sleep 3s
$busybox chroot $mnt run-parts -a start /etc/init.d/
fi

######### STARTING ACTUAL BOOTLINUX ENVIROMENT #########
$busybox chroot $mnt /usr/bin/env su -l
killlinux

######### SHUTTING DOWN BOOTLINUX ENVIROMENT #########
$busybox chroot $mnt run-parts -a stop /etc/init.d/
. ${SCRIPT_PATH%/*}/killlinux $1

exec 2>&1
25 changes: 25 additions & 0 deletions system/bin/bootlinux_debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/system/bin/sh

######### IMPORT BOOTLINUX ENVIRONMENT #########
SCRIPT_PATH=$(readlink -f $0)
. ${SCRIPT_PATH%/*}/bootlinux_env > /sdcard/log.1.txt

######### STARTING run-parts #########
if [ -e $mnt/etc/init.d/ ]; then
echo "Found executables in init.d, sleeping 3 seconds before starting."
sleep 3s
read -r choice?'Run /etc/init.d scripts? (Y/N)--> '
echo ""
if [ $choice = "Y" ]
$busybox chroot $mnt run-parts -a start /etc/init.d/; clear; env su -l
$busybox chroot $mnt run-parts -a stop /etc/init.d/ > /sdcard/log.2.txt
else
$busybox chroot $mnt /usr/bin/env su -l
fi
else
######### STARTING ACTUAL BOOTLINUX ENVIROMENT #########
$busybox chroot $mnt /usr/bin/env su -l
fi

######### SHUTTING DOWN BOOTLINUX ENVIROMENT #########
. ${SCRIPT_PATH%/*}/killlinux $1 > /sdcard/log.3.txt
4 changes: 4 additions & 0 deletions system/bin/bootlinux_env
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/system/bin/sh

exec 2>/dev/null

######### IMPORT BOOTLINUX INITIALIZATION #########
SCRIPT_PATH=$(readlink -f $0)
. ${SCRIPT_PATH%/*}/bootlinux_log
Expand All @@ -25,5 +27,7 @@ export DEX2OATBOOTCLASSPATH=/apex/com.android.art/javalib/core-oj.jar:/apex/com.
unset LD_PRELOAD
unset PREFIX

exec 2>&1

######### TERMINAL SETUP #########
clear
18 changes: 6 additions & 12 deletions system/bin/bootlinux_init
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/system/bin/sh

exec 2>/dev/null

if [ -x /system/xbin/busybox ]; then
busybox=/system/xbin/busybox
elif [ -x /system/bin/busybox ]; then
Expand Down Expand Up @@ -150,6 +152,7 @@ mount_linux_chroot() {
done
cd - 2>&1 > /dev/null
fi
exec 2>/dev/null
mkdir -p $mnt/data/data
mkdir -p $mnt/data/dalvik-cache
mkdir -p $mnt/vendor
Expand All @@ -165,14 +168,6 @@ mount_linux_chroot() {
# ln -s /dev/tun /dev/net/tun 2> /dev/null

######### SET DNS ########

# setup
rm $mnt/etc/resolv.conf
touch $mnt/etc/resolv.conf

# add two public dns entries
echo "nameserver 1.1.1.1" >> $mnt/etc/resolv.conf
echo "nameserver 1.0.0.1" >> $mnt/etc/resolv.conf
chmod 644 $mnt/etc/resolv.conf

######### MOUNTING FILESYSTEM IN CHROOT #########
Expand All @@ -192,7 +187,7 @@ mount_linux_chroot() {
[ ! -d $mnt/dev/pts ] && mkdir -p $mnt/dev/pts
$busybox mount -t devpts devpts $mnt/dev/pts && bllog "[+] mounted /dev/pts"
fi

######### MOUNT DEV SHM ########
if [ ! "$(mountpoint $mnt/dev/shm 2> /dev/null | grep 'is a')" ]; then
[ ! -d $mnt/dev/shm ] && mkdir -p $mnt/dev/shm
Expand Down Expand Up @@ -279,9 +274,6 @@ mount_linux_chroot() {

# NETWORK SETTINGS #
$busybox sysctl -w net.ipv4.ip_forward=1
echo "127.0.0.1 localhost linux" > $mnt/etc/hosts
echo "::1 localhost ip6-localhost ip6-loopback" >> $mnt/etc/hosts
echo "linux" > $mnt/proc/sys/kernel/hostname
echo "The Linux chroot has been started."
if [ -f /sdcard/debug ]; then
echo " [!] Everytime you mount the linux chroot, please press ENTER to continue. (If chroot is already mounted, this won't prompt.)"
Expand All @@ -302,3 +294,5 @@ else
echo "Missing required folder, exit now...."
exit 1
fi

exec 2>&1
26 changes: 26 additions & 0 deletions system/bin/bootlinux_origin
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/system/bin/sh

exec 2>/dev/null

echo "Warning: You're running origin mode of bootlinux, this means that the autostart of init.d items is suspended."

######### IMPORT BOOTLINUX ENVIRONMENT #########
SCRIPT_PATH=$(readlink -f $0)
. ${SCRIPT_PATH%/*}/bootlinux_env

######### STARTING run-parts #########
# echo "Checking is there are files inside /etc/init.d to start."
# if [ -e $mnt/etc/init.d/ ]; then
# echo "Found executables, sleeping 3 seconds before starting."
# sleep 3s
# $busybox chroot $mnt run-parts -a start /etc/init.d/
# fi

######### STARTING ACTUAL BOOTLINUX ENVIROMENT #########
$busybox chroot $mnt /usr/bin/env su -l

######### SHUTTING DOWN BOOTLINUX ENVIROMENT #########
# $busybox chroot $mnt run-parts -a stop /etc/init.d/
. ${SCRIPT_PATH%/*}/killlinux $1

exec 2>&1
Loading