Skip to content

Commit

Permalink
Update 12-18 19:15
Browse files Browse the repository at this point in the history
  • Loading branch information
lin1328 committed Dec 18, 2024
1 parent 4e425b1 commit ac0e31c
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 83 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ jobs:
local os=$1
local version=$2
sed -i "s/RURIMA_LXC_OS=\".*\"/RURIMA_LXC_OS=\"${os}\"/g" config.conf
sed -i "s/RURIMA_LXC_OS_VERSION=\".*\"/RURIMA_LXC_OS_VERSION=\"${version}\"/g" config.conf
sed -i "s/^RURIMA_LXC_OS=.*/RURIMA_LXC_OS=${os}/g" config.conf
sed -i "s/^RURIMA_LXC_OS_VERSION=.*/RURIMA_LXC_OS_VERSION=${version}/g" config.conf
zip -r "../asl-${os}-${version}.zip" . -x "*.git/*" -x ".github/*"
Expand Down
14 changes: 7 additions & 7 deletions action.sh
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)
PORT=$(sed -n 's/^PORT=\(.*\)/\1/p' "$MODDIR/config.conf")
PID=$("$MODDIR/bin/fuser" "$PORT/tcp" 2>/dev/null)

BETA() {
local PREFIX=/data/user/0/com.termux/files/usr
Expand All @@ -9,13 +9,13 @@ BETA() {
local TMPDIR=$PREFIX/tmp
local BATE=$TMPDIR/asl.sh

if [ ! -d $PREFIX ]; then
if [ ! -d "$PREFIX" ]; then
echo "- TThe environment of Termux is abnormal"
return
fi

cp -f $MODDIR/bate.sh $BATE
chmod 755 $BATE
cp -f "$MODDIR/bate.sh" "$BATE"
chmod 755 "$BATE"

echo "- It will run in Termux soon. Please make sure the network is working properly"
echo "- Check whether Termux is running in the background"
Expand Down Expand Up @@ -55,13 +55,13 @@ update_ssh() {

if [ -n "$PID" ]; then
printf "- Stopping container...\n\n"
"$MODDIR"/container_ctrl.sh stop
"$MODDIR/container_ctrl.sh" stop
sed -i 's|^description=.*|description=\[ stopped🙁 \] Android Subsystem for GNU/Linux Powered by ruri|' "$MODDIR/module.prop"

BETA
else
printf "- Starting up container...\n\n"
"$MODDIR"/container_ctrl.sh start
"$MODDIR/container_ctrl.sh" start

update_ssh
fi
Expand Down
4 changes: 3 additions & 1 deletion bate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ config_new_system() {

if [ $? -eq 0 ]; then
echo "系统 $new_os 基础配置完成"
echoRgb "请牢记你的密码: $sys_password 和端口: $sys_port" 3
return 0
else
echo "系统 $new_os 基础配置失败"
Expand Down Expand Up @@ -1012,7 +1013,8 @@ switch_lxc_os() {
return 1
fi

sed -i "s/RURIMA_LXC_OS=\"[^\"]*\"/RURIMA_LXC_OS=\"$new_os\"/" "$CONFIG_FILE"
sed -i "s/^RURIMA_LXC_OS=.*/RURIMA_LXC_OS=$new_os/" "$CONFIG_FILE"
sed -i "s|^CONTAINER_DIR=.*|CONTAINER_DIR=$BASE_DIR/$new_os|" "$CONFIG_FILE"

if [ $? -eq 0 ]; then
echo "成功将系统切换为 $new_os"
Expand Down
70 changes: 18 additions & 52 deletions config.conf
Original file line number Diff line number Diff line change
@@ -1,66 +1,32 @@
#!/bin/sh
# 本机连接ssh [email protected] -p 22密码123456
# 请根据你自己的网络环境选择是本机(127.0.0.1)、局域网(192.*.*.*)或公网(ipv4地址)来连接 SSH

# Mirror
RURIMA_LXC_MIRROR="images.linuxcontainers.org"
# OS to install.
RURIMA_LXC_MIRROR=images.linuxcontainers.org

# OS to install
# Make sure there is setup/${RURIMA_LXC_OS}.sh
RURIMA_LXC_OS="ubuntu"
# OS version to install.
RURIMA_LXC_OS_VERSION="oracular"
RURIMA_LXC_OS=ubuntu

# Add additional commands other than the system's built-in commands
BUSYBOX_PATHS="
/data/adb/magisk/busybox
/data/adb/ksu/bin/busybox
/data/adb/ap/bin/busybox
"
HOSTNAME="$(getprop ro.product.model)"
PASSWORD="123456"
PORT="22"
CONTAINER_DIR="/data/${RURIMA_LXC_OS}"
# OS version to install
RURIMA_LXC_OS_VERSION=oracular

# In a chroot environment, the default interpreters and service startup commands may not be universal across different systems
case "$RURIMA_LXC_OS" in
archlinux|centos|debian|ubuntu)
SHELL="bash"
;;
alpine)
SHELL="sh"
;;
*)
SHELL="sh"
;;
esac
PASSWORD=123456
PORT=22

# 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)
START_SERVICES="servicectl start sshd"
;;
debian|ubuntu)
START_SERVICES="service ssh start"
;;
alpine)
START_SERVICES="rc-service sshd restart"
;;
*)
START_SERVICES=""
;;
esac
# OS dir to install
# CONTAINER_DIR="/data/${RURIMA_LXC_OS}"


# ruri config

REQUIRE_SUDO="true"
MOUNT_POINT="/data/media/0"
MOUNT_ENTRANCE="/sdcard"
MOUNT_READ_ONLY="true"
UNMASK_DIRS="false"
PRIVILEGED="false"
RUNTIME="false"

REQUIRE_SUDO=true
MOUNT_POINT=/data/media/0
MOUNT_ENTRANCE=/sdcard
MOUNT_READ_ONLY=true
UNMASK_DIRS=false
PRIVILEGED=false
RUNTIME=false


#
19 changes: 18 additions & 1 deletion container_ctrl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ 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)
START_SERVICES="servicectl start sshd"
;;
debian|ubuntu)
START_SERVICES="service ssh start"
;;
alpine)
START_SERVICES="rc-service sshd restart"
;;
*)
START_SERVICES=""
;;
esac

if [ "$REQUIRE_SUDO" = "true" ]; then
mount --bind $CONTAINER_DIR $CONTAINER_DIR
mount -o remount,suid $CONTAINER_DIR
Expand All @@ -42,7 +59,7 @@ ruristart() {
[ "$PRIVILEGED" = "true" ] && ARGS="$ARGS -p"
[ "$RUNTIME" = "true" ] && ARGS="$ARGS -S"

ruri $ARGS $CONTAINER_DIR /bin/$SHELL -c "$START_SERVICES" &
ruri $ARGS "$CONTAINER_DIR" /bin/sh -c "$START_SERVICES" &
echo "- Container started"
}

Expand Down
44 changes: 26 additions & 18 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/bin/busybox" ]; then
busybox_file="$MODPATH/bin/busybox"
else
for path in $BUSYBOX_PATHS; do
if [ -f "$path" ]; then
Expand All @@ -33,32 +33,40 @@ link_busybox() {
fi

if [ -n "$busybox_file" ]; then
mkdir -p "$MODPATH"/bin
mkdir -p "$MODPATH/bin"
# "$busybox_file" --install -s "$MODPATH/bin"
# 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"
ln -s "$busybox_file" "$MODPATH/bin/$cmd"
done
else
abort "- No available Busybox file found Please check your installation environment"
fi
}

inotifyfile() {
id_value=$(sed -n 's/^id=\(.*\)$/\1/p' "$MODPATH"/module.prop)
id_value=$(sed -n 's/^id=\(.*\)$/\1/p' "$MODPATH/module.prop")
MONITORFILE=".${id_value}.service.sh"

sed -i "2c MODULEID=\"$id_value\"" "$MODPATH"/inotify.sh
sed -i "2c MODULEID=\"$id_value\"" "$MODPATH/inotify.sh"
mkdir -p /data/adb/service.d
mv -f "$MODPATH"/inotify.sh /data/adb/service.d/"$MONITORFILE"
chmod +x /data/adb/service.d/"$MONITORFILE"
mv -f "$MODPATH/inotify.sh" "/data/adb/service.d/$MONITORFILE"
chmod +x "/data/adb/service.d/$MONITORFILE"

sed -i "s/inotify.sh/$MONITORFILE/g" "$MODPATH"/uninstall.sh
sed -i "s/inotify.sh/$MONITORFILE/g" "$MODPATH/uninstall.sh"
}

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

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"

Expand Down Expand Up @@ -97,13 +105,13 @@ automatic() {
ui_print "- Please ensure the network environment is stable. The process may take some time, so please be patient!"
ui_print ""
sleep 2
echo "$HOSTNAME" >"$CONTAINER_DIR"/etc/hostname
mkdir -p "$CONTAINER_DIR"/tmp "$CONTAINER_DIR"/usr/local/lib/servicectl/enabled >/dev/null 2>&1
cp "$MODPATH"/setup/setup.sh "$CONTAINER_DIR"/tmp/setup.sh
cp -r "$MODPATH"/setup/servicectl/* "$CONTAINER_DIR"/usr/local/lib/servicectl/
chmod 777 "$CONTAINER_DIR"/tmp/setup.sh "$CONTAINER_DIR"/usr/local/lib/servicectl/servicectl "$CONTAINER_DIR"/usr/local/lib/servicectl/serviced
getprop ro.product.model >"$CONTAINER_DIR/etc/hostname"
mkdir -p "$CONTAINER_DIR/tmp" "$CONTAINER_DIR/usr/local/lib/servicectl/enabled"
cp "$MODPATH/setup/setup.sh" "$CONTAINER_DIR/tmp/setup.sh"
cp -r "$MODPATH/setup/servicectl"/* "$CONTAINER_DIR/usr/local/lib/servicectl/"
chmod 777 "$CONTAINER_DIR/tmp/setup.sh" "$CONTAINER_DIR/usr/local/lib/servicectl/servicectl" "$CONTAINER_DIR/usr/local/lib/servicectl/serviced"

ruri "$CONTAINER_DIR" /bin/"$SHELL" /tmp/setup.sh "$RURIMA_LXC_OS" "$PASSWORD" "$PORT"
ruri "$CONTAINER_DIR" /bin/sh /tmp/setup.sh "$RURIMA_LXC_OS" "$PASSWORD" "$PORT"

inotifyfile
#rm "$CONTAINER_DIR"/tmp/setup.sh
Expand All @@ -122,7 +130,7 @@ main() {
main

# set_perm_recursive $MODPATH 0 0 0755 0644
set_perm "$MODPATH"/container_ctrl.sh 0 0 0755
set_perm "$MODPATH/container_ctrl.sh" 0 0 0755

ui_print ""
ui_print "- Please restart the system"
2 changes: 1 addition & 1 deletion inotify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ while [ $(getprop sys.boot_completed) != 1 ]; do
sleep 2
done

[ ! -f "$MODULEDIR"/disable ] && "$MODULEDIR/container_ctrl.sh" start
[ ! -f "$MODULEDIR/disable" ] && "$MODULEDIR/container_ctrl.sh" start

(
inotifyd - "$MODULEDIR" 2>/dev/null | while read -r events _ file; do
Expand Down
2 changes: 1 addition & 1 deletion uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MODDIR=${0%/*}
"$MODDIR"/container_ctrl.sh stop
CONTAINER_DIR="/data/$(sed -n 's/^RURIMA_LXC_OS="\([^"]*\)"/\1/p' "$MODDIR/config.conf")"
CONTAINER_DIR=$(grep '^CONTAINER_DIR=' "$MODDIR/config.conf" | cut -d '=' -f 2)

rm -f /data/adb/service.d/inotify.sh
umount -lf "$CONTAINER_DIR"/dev
Expand Down

0 comments on commit ac0e31c

Please sign in to comment.