Skip to content

Commit

Permalink
Merge pull request #12 from lin1328/main
Browse files Browse the repository at this point in the history
Add back the mistakenly deleted PATH
  • Loading branch information
Moe-hacker authored Jan 4, 2025
2 parents 2491936 + 5b853e4 commit af5f353
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 69 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
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#^CONTAINER_DIR=.*#CONTAINER_DIR=/data/${os}#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
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
57 changes: 27 additions & 30 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 @@ -177,8 +178,8 @@ Endofpacman2
pacman -Syu --noconfirm
pacman -Sy --noconfirm --needed openssh

ln -s /usr/local/lib/servicectl/serviced /usr/bin/serviced
ln -s /usr/local/lib/servicectl/servicectl /usr/bin/servicectl
ln -sf /usr/local/lib/servicectl/serviced /usr/bin/serviced
ln -sf /usr/local/lib/servicectl/servicectl /usr/bin/servicectl

ssh-keygen -A

Expand Down Expand Up @@ -207,8 +208,8 @@ setup_centos() {
yum install -y openssh-server
yum clean all

ln -s /usr/local/lib/servicectl/serviced /usr/bin/serviced
ln -s /usr/local/lib/servicectl/servicectl /usr/bin/servicectl
ln -sf /usr/local/lib/servicectl/serviced /usr/bin/serviced
ln -sf /usr/local/lib/servicectl/servicectl /usr/bin/servicectl

ssh-keygen -A
}
Expand All @@ -224,8 +225,8 @@ setup_fedora() {
dnf install -y openssh-server
dnf clean all

ln -s /usr/local/lib/servicectl/serviced /usr/bin/serviced
ln -s /usr/local/lib/servicectl/servicectl /usr/bin/servicectl
ln -sf /usr/local/lib/servicectl/serviced /usr/bin/serviced
ln -sf /usr/local/lib/servicectl/servicectl /usr/bin/servicectl

ssh-keygen -A
}
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 af5f353

Please sign in to comment.