Skip to content

Commit

Permalink
Update 01-03 20:40
Browse files Browse the repository at this point in the history
  • Loading branch information
lin1328 committed Jan 3, 2025
1 parent 9f720d9 commit 7c8d1af
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 63 deletions.
14 changes: 7 additions & 7 deletions action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ update_ssh() {

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

BETA
if "$MODDIR/container_ctrl.sh" stop; then
sed -i 's|^description=.*|description=stopped🙁 Android Subsystem for GNU/Linux Powered by ruri|' "$MODDIR/module.prop"
BETA
fi
else
printf "- Starting up container...\n\n"
"$MODDIR/container_ctrl.sh" start

update_ssh
if "$MODDIR/container_ctrl.sh" start; then
update_ssh
fi
fi

countdown=3
Expand Down
10 changes: 5 additions & 5 deletions config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ RURIMA_LXC_OS=ubuntu
# OS version to install
RURIMA_LXC_OS_VERSION=oracular

# OS dir to install
# The actual directory is the `CONTAINER_DIR` in `customize.sh`
# CONTAINER_DIR=/data/${RURIMA_LXC_OS}
CONTAINER_DIR=/data/ubuntu

PASSWORD=123456
PORT=22

Expand All @@ -22,8 +27,3 @@ MOUNT_READ_ONLY=true
UNMASK_DIRS=false
PRIVILEGED=false
RUNTIME=false


# OS dir to install
# The actual directory is the `CONTAINER_DIR` in `customize.sh`
# CONTAINER_DIR=/data/${RURIMA_LXC_OS}
4 changes: 4 additions & 0 deletions container_ctrl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

. "${0%/*}/config.conf"

if [ ! -e "$CONTAINER_DIR/etc/os-release" ]; then
exit 1
fi

ruriumount() {
fuser -k "$CONTAINER_DIR" >/dev/null 2>&1
ruri -U "$CONTAINER_DIR" >/dev/null 2>&1
Expand Down
50 changes: 24 additions & 26 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SKIPUNZIP=0

ASL=
REPLACE="
"
bootinspect() {
Expand All @@ -20,24 +21,21 @@ bootinspect() {

link_busybox() {
local busybox_file=""
local BUSYBOX_PATHS="/data/adb/magisk/busybox /data/adb/ksu/bin/busybox /data/adb/ap/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
busybox_file="$path"
break
fi
done
fi
for path in $BUSYBOX_PATHS; do
if [ -f "$path" ]; then
busybox_file="$path"
break
fi
done

if [ -n "$busybox_file" ]; then
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; do
ln -s "$busybox_file" "$MODPATH/system/xbin/$cmd"
ln -sf "$busybox_file" "$MODPATH/system/xbin/$cmd"
done

if ! inotifyd --help >/dev/null 2>&1; then
Expand All @@ -46,6 +44,9 @@ link_busybox() {
else
abort "- No available Busybox file found Please check your installation environment"
fi

set_perm_recursive "$MODPATH/system/xbin" 0 0 0755 0755
export PATH="$MODPATH/system/xbin:$PATH"
}

inotifyfile() {
Expand All @@ -61,20 +62,13 @@ inotifyfile() {
}

configuration() {
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"

BASE_DIR="/data"
CONTAINER_DIR="${BASE_DIR}/${RURIMA_LXC_OS}"
echo "CONTAINER_DIR=${BASE_DIR}/${RURIMA_LXC_OS}" >> "$MODPATH/config.conf"
sed -i "s|^CONTAINER_DIR=.*|CONTAINER_DIR=$CONTAINER_DIR|" "$MODPATH/config.conf"

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' | \
tr '|' ' ' | \
tr '\n' ' ')
SUPPORT=$(sed -nE 's/^OS_LIST="([^"]+)"/\1/p' "$MODPATH/setup/setup.sh")

if ! echo "$SUPPORT" | grep -qw "$RURIMA_LXC_OS"; then
abort "- $RURIMA_LXC_OS is not supported by the setup script"
Expand Down Expand Up @@ -116,19 +110,22 @@ automatic() {
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/sh /tmp/setup.sh "$RURIMA_LXC_OS" "$PASSWORD" "$PORT"

inotifyfile
ruri -U "$CONTAINER_DIR"

ui_print "- Automated installation completed!"
ui_print "- Note: Please change the default password. Exposing an SSH port with password authentication instead of key-based authentication is always a high-risk behavior!"
}

main() {
bootinspect
configuration
link_busybox
automatic
ruri -U "$CONTAINER_DIR"

if [ -z "$ASL" ]; then
configuration
automatic
fi

inotifyfile
}

main
Expand All @@ -137,4 +134,5 @@ main
set_perm "$MODPATH/container_ctrl.sh" 0 0 0755

ui_print ""
ui_print "- Please restart the system"
(sleep 5 && reboot) &
ui_print "The system will restart in 5 seconds..."
2 changes: 1 addition & 1 deletion inotify.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
MODULEID="moduleid"
MODULEID="asl"
MODULEDIR="/data/adb/modules/$MODULEID"

if command -v magisk >/dev/null 2>&1; then
Expand Down
45 changes: 21 additions & 24 deletions setup/setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LXC_OS=$1
PASSWORD=$2
PORT=$3
OS_LIST="alpine archlinux centos debian fedora kali ubuntu"

configure_dns_host() {
if [ -L /etc/resolv.conf ]; then
Expand Down Expand Up @@ -268,36 +269,32 @@ configure_ssh() {
}

main() {
configure_dns_host
local valid=0

create_groups
for os in $OS_LIST; do
if [ "$LXC_OS" = "$os" ]; then
valid=1
break
fi
done

add_user_to_groups
if [ "$valid" -eq 0 ]; then
echo "Unsupported LXC operating system '$LXC_OS'"
return 1
fi

configure_dns_host
create_groups
add_user_to_groups
echo "root:${PASSWORD:-123456}" | chpasswd

case "$LXC_OS" in
archlinux)
setup_archlinux
;;
alpine)
setup_alpine
;;
centos)
setup_centos
;;
debian|ubuntu)
setup_debian
;;
fedora)
setup_fedora
;;
kali)
setup_kali
;;
*)
echo "Unsupported LXC OS: $LXC_OS"
;;
archlinux) setup_archlinux ;;
alpine) setup_alpine ;;
centos) setup_centos ;;
debian|ubuntu) setup_debian ;;
fedora) setup_fedora ;;
kali) setup_kali ;;
esac

configure_ssh
Expand Down

0 comments on commit 7c8d1af

Please sign in to comment.