Skip to content

Commit

Permalink
Merge pull request #11 from lin1328/main
Browse files Browse the repository at this point in the history
Fix two outstanding issues
  • Loading branch information
Moe-hacker authored Dec 28, 2024
2 parents afbbb9f + 9f720d9 commit 2491936
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 42 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2 align="center">Android Subsystem for GNU/Linux</h2>

[![Repo size](https://img.shields.io/github/repo-size/lin1328/asl?logo=github&logoColor=white)](https://github.com/lin1328/asl)
[![Repo size](https://img.shields.io/github/repo-size/Moe-hacker/asl?logo=github&logoColor=white)](https://github.com/Moe-hacker/asl)

<details>
<summary><strong>Currently Supported Systems</strong></summary>
Expand Down Expand Up @@ -37,7 +37,7 @@
> - If there are any bugs, please report them. Compatibility with all devices is not guaranteed
> - If you install the module twice, it will backup old container_dir and install a new container
> - you can install multipe OS by changeing the module id and ssh port, but this action not supported officially
## How to connect:
## How to connect
Use port 22, user root and password 123456 by default,
but, please change the password once you connected to the container, and it's better to use ssh key instead of password login, note that please do not expose the ssh port to the pubnet.
## About the Binary
Expand Down
6 changes: 3 additions & 3 deletions action.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MODDIR=${0%/*}
PORT=$(sed -n 's/^PORT=\(.*\)/\1/p' "$MODDIR/config.conf")
PID=$("$MODDIR/bin/fuser" "$PORT/tcp" 2>/dev/null)
PID=$(fuser "$PORT/tcp" 2>/dev/null)

BETA() {
local PREFIX=/data/user/0/com.termux/files/usr
Expand Down Expand Up @@ -43,13 +43,13 @@ BETA() {
}

update_ssh() {
local rootfs="/data/$(sed -n 's/^RURIMA_LXC_OS="\([^"]*\)"/\1/p' "$MODDIR/config.conf")"
local rootfs=$(sed -n 's/^CONTAINER_DIR=\(.*\)$/\1/p' "$MODDIR/config.conf")

sleep 2
if lsof | grep "$rootfs" | awk '{print $2}' | uniq | grep -q "sshd"; then
sed -i 's|^description=.*|description=\[ running😉 \] Android Subsystem for GNU/Linux Powered by ruri|' "$MODDIR/module.prop"
else
sed -i 's|^description=.*|description=\[ running⚠️ \] Android Subsystem for GNU/Linux Powered by ruri|' "$MODDIR/module.prop"
sed -i 's|^description=.*|description=\[ SSH exception⚠️ \] Android Subsystem for GNU/Linux Powered by ruri|' "$MODDIR/module.prop"
fi
}

Expand Down
5 changes: 2 additions & 3 deletions bate.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ echo
echo "Welcome to Termux"
echoRgb "欢迎使用 Android Subsystem for GNU/Linux" 4

for cmd in curl wget rsync; do
for cmd in curl wget; do
command -v "$cmd" >/dev/null 2>&1 || abort "! 依赖的命令 $cmd 未安装"
done

Expand Down Expand Up @@ -744,7 +744,7 @@ download_system_image() {

IFS=';' read -r distro version arch variant date path <<< "$version_info"

local download_url="${base_url}${path}/rootfs.tar.xz"
local download_url="${base_url}${path}rootfs.tar.xz"
local download_file="/data/local/tmp/${os_name}_${version}_rootfs.tar.xz"

mkdir -p "$target_dir" /data/local/tmp
Expand Down Expand Up @@ -925,7 +925,6 @@ delete_system() {
rm -rf "$sys_path"

echo "系统 $os_name 删除成功"
pause_func
return 0
}

Expand Down
Binary file removed bin/ruri
Binary file not shown.
12 changes: 4 additions & 8 deletions config.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# 本机连接ssh [email protected] -p 22密码123456
# 请根据你自己的网络环境选择是本机(127.0.0.1)、局域网(192.*.*.*)或公网(ipv4地址)来连接 SSH

# Mirror
RURIMA_LXC_MIRROR=images.linuxcontainers.org
RURIMA_LXC_MIRROR_FALLBACK=mirrors.tuna.tsinghua.edu.cn/lxc-images

# OS to install
# Make sure there is setup/${RURIMA_LXC_OS}.sh
# Make sure there is ${RURIMA_LXC_OS} in setup/setup.sh
RURIMA_LXC_OS=ubuntu

# OS version to install
Expand All @@ -15,9 +12,6 @@ RURIMA_LXC_OS_VERSION=oracular
PASSWORD=123456
PORT=22

# OS dir to install
# CONTAINER_DIR="/data/${RURIMA_LXC_OS}"


# ruri config

Expand All @@ -30,4 +24,6 @@ PRIVILEGED=false
RUNTIME=false


#
# OS dir to install
# The actual directory is the `CONTAINER_DIR` in `customize.sh`
# CONTAINER_DIR=/data/${RURIMA_LXC_OS}
11 changes: 3 additions & 8 deletions container_ctrl.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/bin/sh

init_setup() {
MODDIR=${0%/*}
export PATH="$MODDIR/bin:$PATH"
. "$MODDIR/config.conf"
}
. "${0%/*}/config.conf"

ruriumount() {
init_setup
fuser -k "$CONTAINER_DIR" >/dev/null 2>&1
ruri -U "$CONTAINER_DIR" >/dev/null 2>&1
umount -lvf "$CONTAINER_DIR" 2>/dev/null
Expand All @@ -22,11 +17,11 @@ ruriumount() {
ruristart() {
ruriumount

# The servicectl command is an open-source project. If you find it inconvenient to use, you can opt for other startup commands It is not mandatory
# e.g. /usr/sbin/sshd
case "$RURIMA_LXC_OS" in
archlinux|centos|fedora)
START_SERVICES="servicectl start sshd"
# you can opt for other startup commands It is not mandatory
# e.g. /usr/sbin/sshd
;;
debian|kali|ubuntu)
START_SERVICES="service ssh start"
Expand Down
24 changes: 12 additions & 12 deletions customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ bootinspect() {
link_busybox() {
local busybox_file=""

if [ -f "$MODPATH/bin/busybox" ]; then
busybox_file="$MODPATH/bin/busybox"
if [ -f "$MODPATH/system/xbin/busybox" ]; then
busybox_file="$MODPATH/system/xbin/busybox"
else
for path in $BUSYBOX_PATHS; do
if [ -f "$path" ]; then
Expand All @@ -33,12 +33,16 @@ link_busybox() {
fi

if [ -n "$busybox_file" ]; then
mkdir -p "$MODPATH/bin"
# "$busybox_file" --install -s "$MODPATH/bin"
mkdir -p "$MODPATH/system/xbin"
# "$busybox_file" --install -s "$MODPATH/system/xbin"
# This method creates links pointing to all commands of busybox, so it is not recommended. The following is an alternative approach for creating symbolic links pointing to the busybox file for specific commands
for cmd in fuser inotifyd; do
ln -s "$busybox_file" "$MODPATH/bin/$cmd"
for cmd in fuser; do
ln -s "$busybox_file" "$MODPATH/system/xbin/$cmd"
done

if ! inotifyd --help >/dev/null 2>&1; then
ln -sf "$busybox_file" "$MODPATH/system/xbin/inotifyd"
fi
else
abort "- No available Busybox file found Please check your installation environment"
fi
Expand All @@ -57,19 +61,15 @@ inotifyfile() {
}

configuration() {
set_perm_recursive "$MODPATH/bin" 0 0 0755 0755
set_perm_recursive "$MODPATH/system/xbin" 0 0 0755 0755
. "$MODPATH/config.conf"

BUSYBOX_PATHS="/data/adb/magisk/busybox
/data/adb/ksu/bin/busybox
/data/adb/ap/bin/busybox"
BUSYBOX_PATHS="/data/adb/magisk/busybox /data/adb/ksu/bin/busybox /data/adb/ap/bin/busybox"

BASE_DIR="/data"
CONTAINER_DIR="${BASE_DIR}/${RURIMA_LXC_OS}"
echo "CONTAINER_DIR=${BASE_DIR}/${RURIMA_LXC_OS}" >> "$MODPATH/config.conf"

export PATH="$MODPATH/bin:$PATH"

CASE=$(sed -n '/case "\$LXC_OS"/,/^[[:space:]]*esac/p' "$MODPATH/setup/setup.sh")
SUPPORT=$(echo "$CASE" | \
sed -n 's/^[[:space:]]*\([a-zA-Z0-9|]*\))$/\1/p' | \
Expand Down
4 changes: 1 addition & 3 deletions inotify.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if command -v magisk >/dev/null 2>&1; then
fi
fi

export PATH="$MODULEDIR/bin:$PATH"

while [ $(getprop sys.boot_completed) != 1 ]; do
sleep 2
done
Expand All @@ -35,4 +33,4 @@ done
) &
pid=$!

sed -i "6c description=[ PID=$pid ] This container can be quickly controlled by enabling/disabling" "$MODULEDIR/module.prop"
sed -i "6c description=[ PID=$pid ] This container can be quickly controlled by enabling/disabling" "$MODULEDIR/module.prop"
2 changes: 1 addition & 1 deletion module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=asl
name=Android Subsystem for GNU/Linux
version=v1.0.0
version=v1.0.1
versionCode=202412
author=Moe-hacker & Lin1328
description=Android Subsystem for GNU/Linux Powered by ruri
Empty file modified setup/servicectl/servicectl
100755 → 100644
Empty file.
Empty file modified setup/servicectl/serviced
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions setup/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ configure_ssh() {
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
fi

if grep -Eq "^#?\s*PasswordAuthentication" /etc/ssh/sshd_config; then
sed -i 's/^#\?\s*PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
if grep -Eq "^#?\s*PasswordAuthentication\s" /etc/ssh/sshd_config; then
sed -i 's/^#\?\s*PasswordAuthentication\s.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
else
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
fi
Expand Down
0 bin/curl → system/xbin/curl
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
0 bin/file → system/xbin/file
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
0 bin/gzip → system/xbin/gzip
100755 → 100644
File renamed without changes.
File renamed without changes.
Binary file added system/xbin/ruri
Binary file not shown.
0 bin/rurima → system/xbin/rurima
100755 → 100644
File renamed without changes.
File renamed without changes.
0 bin/tar → system/xbin/tar
100755 → 100644
File renamed without changes.
0 bin/xz → system/xbin/xz
100755 → 100644
File renamed without changes.

0 comments on commit 2491936

Please sign in to comment.