Skip to content

Commit 4e1c58a

Browse files
authored
Merge pull request #4 from lin1328/main
Add support for CentOS LXC
2 parents 4cc7bce + 455bfca commit 4e1c58a

File tree

16 files changed

+405
-37
lines changed

16 files changed

+405
-37
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
- alpine
55
- 3.20
66
- `edge`
7-
- ubuntu
8-
- focal
9-
- `jammy`
10-
- noble
11-
- `oracular`
7+
- centos
8+
- `9-Stream`
129
- debian
1310
- `bookworm`
1411
- bullseye
1512
- buster
1613
- trixie
14+
- ubuntu
15+
- focal
16+
- `jammy`
17+
- noble
18+
- `oracular`
1719
# Note:
1820
This module is only for armv8+
1921
Tested only on the marked system versions, if there's any bugs, please report

config.conf

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CONTAINER_DIR="/data/${RURIMA_LXC_OS}"
2323

2424
# In a chroot environment, the default interpreters and service startup commands may not be universal across different systems
2525
case "$RURIMA_LXC_OS" in
26-
ubuntu|debian|archlinux)
26+
archlinux|centos|debian|ubuntu)
2727
SHELL="bash"
2828
;;
2929
alpine)
@@ -34,22 +34,18 @@ case "$RURIMA_LXC_OS" in
3434
;;
3535
esac
3636

37+
# 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
38+
# e.g. /usr/sbin/sshd
3739
case "$RURIMA_LXC_OS" in
38-
ubuntu|debian)
39-
START_SERVICES="service ssh start"
40-
;;
41-
arch|archlinux)
42-
START_SERVICES="/usr/sbin/sshd"
40+
archlinux|centos)
41+
START_SERVICES="servicectl start sshd"
4342
;;
44-
centos|rhel)
45-
START_SERVICES=""
43+
debian|ubuntu)
44+
START_SERVICES="service ssh start"
4645
;;
4746
alpine)
4847
START_SERVICES="rc-service sshd restart"
4948
;;
50-
kali)
51-
START_SERVICES=""
52-
;;
5349
*)
5450
:
5551
;;

customize.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ bootinspect() {
1313
ui_print "- Install from Magisk"
1414
ui_print "- Magisk Version:$MAGISK_VER(App)+ $MAGISK_VER_CODE"
1515
else
16-
ui_print "- Unsupported installation mode. Please install from the application (Magisk/KernelSu/Apatch)"
16+
abort "- Unsupported installation mode. Please install from the application (Magisk/KernelSu/Apatch)"
1717
fi
18+
[ "$ARCH" != "arm64" ] && abort "- Unsupported platform: $ARCH" || ui_print "- Device platform: $ARCH"
1819
}
1920

2021
link_busybox() {
@@ -61,32 +62,35 @@ configuration() {
6162

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

64-
if [[ -e $CONTAINER_DIR/* ]]; then
65+
if [[ -d $CONTAINER_DIR ]]; then
6566
ui_print "- Already installed"
6667
ruri -U "$CONTAINER_DIR"
67-
rm -rf "$CONTAINER_DIR"
68-
ui_print "- Uninstall the container and clean up related directories and files"
68+
mv -f "$CONTAINER_DIR" "$CONTAINER_DIR".old
69+
ui_print "- Shut down the container and back up the relevant directories and files to the ${RURIMA_LXC_OS}.old"
6970
fi
7071
}
7172

7273
automatic() {
7374
ui_print "- A network connection is required to download the root filesystem. Please connect to WiFi before installation whenever possible"
7475
ui_print "- Downloading the root filesystem using the source ${RURIMA_LXC_MIRROR}..."
76+
7577
rurima lxc pull -n -m ${RURIMA_LXC_MIRROR} -o ${RURIMA_LXC_OS} -v ${RURIMA_LXC_OS_VERSION} -s "$CONTAINER_DIR"
78+
7679
ui_print "- Starting the chroot environment to perform automated installation..."
7780
ui_print "- Please ensure the network environment is stable. The process may take some time, so please be patient!"
7881
ui_print ""
7982
sleep 3
8083
echo "$HOSTNAME" >"$CONTAINER_DIR"/etc/hostname
81-
mkdir "$CONTAINER_DIR"/tmp >/dev/null 2>&1
84+
mkdir -p "$CONTAINER_DIR"/tmp "$CONTAINER_DIR"/usr/local/lib/servicectl/enabled >/dev/null 2>&1
8285
cp "$MODPATH/setup/${RURIMA_LXC_OS}.sh" "$CONTAINER_DIR"/tmp/setup.sh
83-
chmod 777 "$CONTAINER_DIR"/tmp/setup.sh
86+
cp -r "$MODPATH"/setup/servicectl/* "$CONTAINER_DIR"/usr/local/lib/servicectl/
87+
chmod 777 "$CONTAINER_DIR"/tmp/setup.sh "$CONTAINER_DIR"/usr/local/lib/servicectl/servicectl "$CONTAINER_DIR"/usr/local/lib/servicectl/serviced
8488
sed -i "s/PASSWORD=\"\"/PASSWORD=\"$PASSWORD\"/g" "$CONTAINER_DIR"/tmp/setup.sh
8589
sed -i "s/PORT=\"\"/PORT=\"$PORT\"/g" "$CONTAINER_DIR"/tmp/setup.sh
90+
8691
ruri "$CONTAINER_DIR" /bin/"$SHELL" /tmp/setup.sh
8792

8893
inotifyfile
89-
9094
#rm "$CONTAINER_DIR"/tmp/setup.sh
9195
ui_print "- Automated installation completed!"
9296
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!"

inotify.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if command -v magisk 2>&1 >/dev/null; then
1010
fi
1111

1212
until [ $(getprop sys.boot_completed) -eq 1 ]; do
13-
sleep 3
13+
sleep 2
1414
done
1515

1616
[ ! -f "$MODULEDIR"/disable ] && "$MODULEDIR"/start.sh
@@ -39,5 +39,8 @@ sed -i "6cdescription=$DESCRIPTION" "$MODULEDIR"/module.prop
3939
done
4040
) &
4141

42+
pid=$!
43+
sed -i "s/^pid=\".*\"$/pid=\"$pid\"/" "$MODULEDIR/service.sh"
44+
4245
# If issues arise after installation, please uncomment. After restarting the system, enable/disable the module, and then check the "debug.log" output file in the current directory to determine whether the monitoring script is functioning properly
4346
# After checking, please delete or comment out line 22, as no log cleanup operation has been added.

module.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id=asl
22
name=Android Subsystem for GNU/Linux
3-
version=v0.0.1
4-
versionCode=202411
3+
version=v0.0.2
4+
versionCode=202412
55
author=Moe-hacker
66
description=Android Subsystem for GNU/Linux Powered by ruri

post-fs-data.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

service.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
MODDIR=${0%/*}
3+
pid=""
4+
5+
while [ $(getprop sys.boot_completed) != 1 ]; do
6+
sleep 3
7+
done
8+
9+
if [ -z "$pid" ] || ! kill -0 "$pid" 2>/dev/null; then
10+
"$MODDIR"/start.sh
11+
else
12+
sed -i 's/^pid=".*"/pid=""/' "$(realpath "$0")"
13+
fi

setup/alpine.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ grep -q "^#*PasswordAuthentication" /etc/ssh/sshd_config || echo "PasswordAuthen
2424
sed -i 's/^#*PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
2525
sed -i 's/^UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
2626
sed -i "s/^#Port 22/Port ${PORT}/" /etc/ssh/sshd_config
27-
# rm $(readlink -f $0)

setup/archlinux.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PASSWORD=""
22
PORT=""
33
rm -rf /etc/resolv.conf && touch /etc/resolv.conf
4-
echo "nameserver 1.0.0.1" >> /etc/resolv.conf
4+
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
55
echo "nameserver 114.114.114.114" >> /etc/resolv.conf
66
echo "nameserver 2606:4700:4700::1111" >> /etc/resolv.conf
77
groupadd -g 1000 aid_system 2>/dev/null || groupadd -g 1074 aid_system 2>/dev/null
@@ -141,13 +141,21 @@ pacman-key --populate archlinuxarm
141141
pacman -Sy --noconfirm archlinux-keyring archlinuxarm-keyring
142142
pacman -Rs linux-aarch64 linux-firmware --noconfirm
143143
pacman -Syu --noconfirm
144-
pacman -Sy --noconfirm --needed sudo openssh
144+
pacman -Sy --noconfirm --needed openssh
145145
# When packaging a software package (such as an AUR package) using `makepkg`, you may encounter an issue where the system cannot enter the fakeroot environment because it is not started by systemd and does not have SYSV pipes and message queues
146146
# To resolve this issue, download the appropriate `fakeroot-tcp` for your system =>>https://pkgs.org/download/fakeroot-tcp
147147
# pacman -S --overwrite '*' yay # It is necessary to compile `archlinuxcn-keyring` by yourself
148-
sed -i "/^# *%wheel *ALL=(ALL:ALL) ALL$/s/^# *//" /etc/sudoers
148+
# sed -i "/^# *%wheel *ALL=(ALL:ALL) ALL$/s/^# *//" /etc/sudoers
149149
sed -i "s/^#PermitRootLogin.*/PermitRootLogin yes/" /etc/ssh/sshd_config
150150
sed -i "s/^#PasswordAuthentication.*/PasswordAuthentication yes/" /etc/ssh/sshd_config
151151
sed -i "s/^UsePAM yes/UsePAM no/" /etc/ssh/sshd_config
152152
sed -i "s/^#Port 22/Port 22/" /etc/ssh/sshd_config
153-
ssh-keygen -A
153+
ln -s /usr/local/lib/servicectl/serviced /usr/bin/serviced
154+
ln -s /usr/local/lib/servicectl/servicectl /usr/bin/servicectl
155+
# ln -s /usr/lib/systemd/system/sshd.service /usr/local/lib/servicectl/enabled/sshd.service
156+
# if grep -q "java" /usr/local/lib/servicectl/enabled/sshd.service; then
157+
# rm -f /usr/local/lib/servicectl/enabled/sshd.service
158+
# echo "/usr/lib/systemd/system/sshd.service" > /usr/local/lib/servicectl/enabled/sshd.service
159+
# # cat /usr/lib/systemd/system/sshd.service > /usr/local/lib/servicectl/enabled/sshd.service
160+
# fi
161+
ssh-keygen -A

setup/centos.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
PASSWORD=""
2+
PORT=""
3+
rm -rf /etc/resolv.conf && touch /etc/resolv.conf
4+
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
5+
echo "nameserver 114.114.114.114" >> /etc/resolv.conf
6+
groupadd -g 1000 aid_system 2>/dev/null || groupadd -g 1074 aid_system 2>/dev/null
7+
groupadd -g 1001 aid_radio
8+
groupadd -g 1002 aid_bluetooth
9+
groupadd -g 1003 aid_graphics
10+
groupadd -g 1004 aid_input
11+
groupadd -g 1005 aid_audio
12+
groupadd -g 1006 aid_camera
13+
groupadd -g 1007 aid_log
14+
groupadd -g 1008 aid_compass
15+
groupadd -g 1009 aid_mount
16+
groupadd -g 1010 aid_wifi
17+
groupadd -g 1011 aid_adb
18+
groupadd -g 1012 aid_install
19+
groupadd -g 1013 aid_media
20+
groupadd -g 1014 aid_dhcp
21+
groupadd -g 1015 aid_sdcard_rw
22+
groupadd -g 1016 aid_vpn
23+
groupadd -g 1017 aid_keystore
24+
groupadd -g 1018 aid_usb
25+
groupadd -g 1019 aid_drm
26+
groupadd -g 1020 aid_mdnsr
27+
groupadd -g 1021 aid_gps
28+
groupadd -g 1023 aid_media_rw
29+
groupadd -g 1024 aid_mtp
30+
groupadd -g 1026 aid_drmrpc
31+
groupadd -g 1027 aid_nfc
32+
groupadd -g 1028 aid_sdcard_r
33+
groupadd -g 1029 aid_clat
34+
groupadd -g 1030 aid_loop_radio
35+
groupadd -g 1031 aid_media_drm
36+
groupadd -g 1032 aid_package_info
37+
groupadd -g 1033 aid_sdcard_pics
38+
groupadd -g 1034 aid_sdcard_av
39+
groupadd -g 1035 aid_sdcard_all
40+
groupadd -g 1036 aid_logd
41+
groupadd -g 1037 aid_shared_relro
42+
groupadd -g 1038 aid_dbus
43+
groupadd -g 1039 aid_tlsdate
44+
groupadd -g 1040 aid_media_ex
45+
groupadd -g 1041 aid_audioserver
46+
groupadd -g 1042 aid_metrics_coll
47+
groupadd -g 1043 aid_metricsd
48+
groupadd -g 1044 aid_webserv
49+
groupadd -g 1045 aid_debuggerd
50+
groupadd -g 1046 aid_media_codec
51+
groupadd -g 1047 aid_cameraserver
52+
groupadd -g 1048 aid_firewall
53+
groupadd -g 1049 aid_trunks
54+
groupadd -g 1050 aid_nvram
55+
groupadd -g 1051 aid_dns
56+
groupadd -g 1052 aid_dns_tether
57+
groupadd -g 1053 aid_webview_zygote
58+
groupadd -g 1054 aid_vehicle_network
59+
groupadd -g 1055 aid_media_audio
60+
groupadd -g 1056 aid_media_video
61+
groupadd -g 1057 aid_media_image
62+
groupadd -g 1058 aid_tombstoned
63+
groupadd -g 1059 aid_media_obb
64+
groupadd -g 1060 aid_ese
65+
groupadd -g 1061 aid_ota_update
66+
groupadd -g 1062 aid_automotive_evs
67+
groupadd -g 1063 aid_lowpan
68+
groupadd -g 1064 aid_hsm
69+
groupadd -g 1065 aid_reserved_disk
70+
groupadd -g 1066 aid_statsd
71+
groupadd -g 1067 aid_incidentd
72+
groupadd -g 1068 aid_secure_element
73+
groupadd -g 1069 aid_lmkd
74+
groupadd -g 1070 aid_llkd
75+
groupadd -g 1071 aid_iorapd
76+
groupadd -g 1072 aid_gpu_service
77+
groupadd -g 1073 aid_network_stack
78+
groupadd -g 2000 aid_shell
79+
groupadd -g 2001 aid_cache
80+
groupadd -g 2002 aid_diag
81+
groupadd -g 2900 aid_oem_reserved_start
82+
groupadd -g 2999 aid_oem_reserved_end
83+
groupadd -g 3001 aid_net_bt_admin
84+
groupadd -g 3002 aid_net_bt
85+
groupadd -g 3003 aid_inet
86+
groupadd -g 3004 aid_net_raw
87+
groupadd -g 3005 aid_net_admin
88+
groupadd -g 3006 aid_net_bw_stats
89+
groupadd -g 3007 aid_net_bw_acct
90+
groupadd -g 3009 aid_readproc
91+
groupadd -g 3010 aid_wakelock
92+
groupadd -g 3011 aid_uhid
93+
groupadd -g 9997 aid_everybody
94+
groupadd -g 9998 aid_misc
95+
groupadd -g 9999 aid_nobody
96+
groupadd -g 10000 aid_app_start
97+
groupadd -g 19999 aid_app_end
98+
groupadd -g 20000 aid_cache_gid_start
99+
groupadd -g 29999 aid_cache_gid_end
100+
groupadd -g 30000 aid_ext_gid_start
101+
groupadd -g 39999 aid_ext_gid_end
102+
groupadd -g 40000 aid_ext_cache_gid_start
103+
groupadd -g 49999 aid_ext_cache_gid_end
104+
groupadd -g 50000 aid_shared_gid_start
105+
groupadd -g 59999 aid_shared_gid_end
106+
groupadd -g 99000 aid_isolated_start
107+
groupadd -g 99999 aid_isolated_end
108+
groupadd -g 100000 aid_user_offset
109+
usermod -a -G aid_system,aid_radio,aid_bluetooth,aid_graphics,aid_input,aid_audio,aid_camera,aid_log,aid_compass,aid_mount,aid_wifi,aid_adb,aid_install,aid_media,aid_dhcp,aid_sdcard_rw,aid_vpn,aid_keystore,aid_usb,aid_drm,aid_mdnsr,aid_gps,aid_media_rw,aid_mtp,aid_drmrpc,aid_nfc,aid_sdcard_r,aid_clat,aid_loop_radio,aid_media_drm,aid_package_info,aid_sdcard_pics,aid_sdcard_av,aid_sdcard_all,aid_logd,aid_shared_relro,aid_dbus,aid_tlsdate,aid_media_ex,aid_audioserver,aid_metrics_coll,aid_metricsd,aid_webserv,aid_debuggerd,aid_media_codec,aid_cameraserver,aid_firewall,aid_trunks,aid_nvram,aid_dns,aid_dns_tether,aid_webview_zygote,aid_vehicle_network,aid_media_audio,aid_media_video,aid_media_image,aid_tombstoned,aid_media_obb,aid_ese,aid_ota_update,aid_automotive_evs,aid_lowpan,aid_hsm,aid_reserved_disk,aid_statsd,aid_incidentd,aid_secure_element,aid_lmkd,aid_llkd,aid_iorapd,aid_gpu_service,aid_network_stack,aid_shell,aid_cache,aid_diag,aid_oem_reserved_start,aid_oem_reserved_end,aid_net_bt_admin,aid_net_bt,aid_inet,aid_net_raw,aid_net_admin,aid_net_bw_stats,aid_net_bw_acct,aid_readproc,aid_wakelock,aid_uhid,aid_everybody,aid_misc,aid_nobody,aid_app_start,aid_app_end,aid_cache_gid_start,aid_cache_gid_end,aid_ext_gid_start,aid_ext_gid_end,aid_ext_cache_gid_start,aid_ext_cache_gid_end,aid_shared_gid_start,aid_shared_gid_end,aid_isolated_start,aid_isolated_end,aid_user_offset root 2>/dev/null
110+
usermod -g aid_inet _apt 2>/dev/null
111+
echo "root:${PASSWORD}" | chpasswd
112+
yum update -y
113+
yum install -y openssh-server
114+
yum clean all
115+
sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
116+
sed -i 's/^#PasswordAuthentication/PasswordAuthentication/' /etc/ssh/sshd_config
117+
sed -i 's/^UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
118+
sed -i "s/^#Port 22/Port ${PORT}/" /etc/ssh/sshd_config
119+
ln -s /usr/local/lib/servicectl/serviced /usr/bin/serviced
120+
ln -s /usr/local/lib/servicectl/servicectl /usr/bin/servicectl
121+
ssh-keygen -A

0 commit comments

Comments
 (0)