Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
I
initrd
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
initrd
Commits
c668fc99
Kaydet (Commit)
c668fc99
authored
Nis 01, 2020
tarafından
Your Name
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
parçaladım
üst
42065ba1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
94 additions
and
68 deletions
+94
-68
functions.sh
src/functions.sh
+13
-25
init.sh
src/init.sh
+5
-6
00-clear.sh
src/scripts/00-clear.sh
+1
-1
01-dmesg.sh
src/scripts/01-dmesg.sh
+2
-0
02-modules.sh
src/scripts/02-modules.sh
+0
-0
03-fsck.sh
src/scripts/03-fsck.sh
+0
-0
98-fsmount.sh
src/scripts/98-fsmount.sh
+29
-27
99-fsswitch.sh
src/scripts/99-fsswitch.sh
+21
-0
vars.sh
src/vars.sh
+23
-9
No files found.
src/functions.sh
Dosyayı görüntüle @
c668fc99
...
...
@@ -13,16 +13,21 @@ generate_rootfs(){
run_modules
(){
for
i
in
$(
ls
/scripts |
sort
)
do
debug
"Running
$i
"
.
/scripts/
$i
done
}
mount_handler
(){
msg
"Mount handler running"
/busybox mount
-t
devtmpfs dev /dev
||
true
/busybox mount
-t
proc proc /proc
||
true
/busybox mount
-t
sysfs sys /sys
||
true
/busybox mount
-t
tmpfs tmpfs /tmp
||
true
/busybox mount
-t
tmpfs tmpfs /run
||
true
/busybox mount
-t
devtmpfs dev /dev
-o
nosuid,noexec,nodev
||
true
/busybox mount
-t
proc proc /proc
-o
nosuid,noexec,nodev
||
true
/busybox mount
-t
sysfs sys /sys
-o
nosuid,noexec,nodev
||
true
/busybox mount
-t
tmpfs tmpfs /tmp
-o
nosuid,noexec,nodev
||
true
/busybox mount
-t
tmpfs tmpfs /run
-o
nosuid,noexec,nodev
||
true
if
[
-e
/sys/firmware/efi
]
;
then
msg
"UEFI mode detected."
mount
-t
efivarfs efivarfs /sys/firmware/efi/efivars
-o
nosuid,nodev,noexec
fi
}
parse_cmdline
(){
for
i
in
$(
cat
/proc/cmdline
)
...
...
@@ -30,37 +35,20 @@ parse_cmdline(){
export
$i
done
}
start_dmesg
(){
msg
"Starting dmesg"
/busybox dmesg
-n
1
||
true
}
msg
()
{
echo
-e
"
${
C_GREEN
}
*
${
C_CLEAR
}
${
@
}
"
}
debug
()
{
[
!
-n
"
$debug
"
]
||
echo
-e
"
${
C_BLUE
}
*
${
C_CLEAR
}
${
@
}
"
}
warn
()
{
echo
-e
"
${
C_YELLOW
}
*
${
C_CLEAR
}
${
@
}
"
}
err
()
{
echo
-e
"
${
C_RED
}
*
${
C_CLEAR
}
${
@
}
"
}
is_file_avaiable
(){
disktmp
=
$(
mktemp
)
rm
-
r
f
$disktmp
rm
-f
$disktmp
mkdir
-p
$disktmp
||
true
mount
-t
auto
"
$1
"
$disktmp
2>/dev/null
[
-f
"
$disktmp
/
$2
"
]
&&
[
-b
"
$1
"
]
status
=
$?
umount
$disktmp
2>/dev/null
umount
-lf
$disktmp
2>/dev/null
return
$status
}
fallback_shell
(){
warn
"Booting dead. Now you are in initial ramdisk."
/busybox setsid cttyhack /bin/sh
||
/busybox sh
}
detect_root
(){
...
...
src/init.sh
Dosyayı görüntüle @
c668fc99
#!/busybox ash
.
/vars
.
/functions
generate_rootfs
start_dmesg
mount_handler
parse_cmdline
detect_root
run_modules
generate_rootfs
||
fallback_shell
mount_handler
||
fallback_shell
parse_cmdline
||
fallback_shell
detect_root
||
fallback_shell
run_modules
||
fallback_shell
while
true
do
/busybox
sleep
999
...
...
src/scripts/00-clear.sh
Dosyayı görüntüle @
c668fc99
#!/busybox sh
[
-n
$debug
]
&&
clear
msg
"Starting
SulinOS
"
msg
"Starting
GNU/Linux
"
[
!
-n
$quiet
]
&&
exec
>
/dev/null
src/scripts/01-dmesg.sh
0 → 100644
Dosyayı görüntüle @
c668fc99
msg
"Starting dmesg"
/busybox dmesg
-n
1
||
true
src/scripts/0
1
-modules.sh
→
src/scripts/0
2
-modules.sh
Dosyayı görüntüle @
c668fc99
File moved
src/scripts/0
2
-fsck.sh
→
src/scripts/0
3
-fsck.sh
Dosyayı görüntüle @
c668fc99
File moved
src/scripts/9
9
-fsmount.sh
→
src/scripts/9
8
-fsmount.sh
Dosyayı görüntüle @
c668fc99
#!/busybox sh
common_boot
(){
debug
"Moving mountpoints"
mount
--move
/sys /rootfs/kernel/sys
mount
--move
/proc /rootfs/kernel/proc
mount
--move
/dev /rootfs/kernel/dev
mount
--move
/tmp /rootfs/tmp
mount
--move
/run /rootfs/run
}
live_boot
(){
list
=
$(
ls
/sys/class/block/ |
grep
".*[0-9]$"
|
grep
-v
loop |
grep
-v
ram |
grep
-v
nbd |
sed
"s|^|/dev/|g"
)
for
part
in
$list
do
debug
"Looking for
$part
"
if
is_file_avaiable
"
$part
"
"main.sfs"
then
debug
"Detected live media:
$part
"
export
root
=
$part
fi
done
mkdir
-p
/root
fs
/a
# upper
mkdir
-p
/root
fs
/b
# workdir
mkdir
-p
/root/a
# upper
mkdir
-p
/root/b
# workdir
mkdir
-p
/live_root/
mkdir
-p
/source/
# lower
mkdir
-p
/output
echo
-e
"Rootfs:
\0
33[32;1m
$root
\0
33[;0m
"
debug
"Mounting live media
"
mount
-t
auto
$root
/output
mount /output/main.sfs /source
umount /rootfs/a 2>/dev/null
umount /rootfs/b 2>/dev/null
mount
-t
overlay
-o
lowerdir
=
/source/,upperdir
=
/rootfs/a/,workdir
=
/rootfs/b overlay /live_root
mount
-t
tmpfs
-o
size
=
100% none /rootfs/a
mount
-t
tmpfs
-o
size
=
100% none /rootfs/b
mount
--move
/sys /live_boot/sys
mount
--move
/proc /live_boot/proc
mount
--move
/dev /live_boot/dev
mount
--move
/tmp /live_boot/tmp
mount
--move
/run /live_boot/run
exec
switch_root /live_root /sbin/init
"
$@
"
||
/busybox sh
umount /root/a 2>/dev/null
umount /root/b 2>/dev/null
debug
"Creating overlayfs"
mount
-t
overlay
-o
lowerdir
=
/source/,upperdir
=
/root/a/,workdir
=
/root/b overlay /rootfs
mount
-t
tmpfs
-o
size
=
100% none /root/a
mount
-t
tmpfs
-o
size
=
100% none /root/b
common_boot
}
normal_boot
(){
debug
"Mounting rootfs"
mkdir
-p
/rootfs
mkdir
-p
/newroot
mount
-t
auto
$root
/newroot
debug
"Creating tmpfs for /"
mount
-t
tmpfs tmpfs /rootfs
mkdir
-p
/rootfs/tmp
mkdir
-p
/rootfs/run
debug
"Creating symlinks"
ln
-s
kernel/dev /rootfs/dev
ln
-s
kernel/sys /rootfs/sys
ln
-s
kernel/proc /rootfs/proc
for
i
in
boot bin lib32 etc kernel lib64 sbin usr data lib root var
do
debug
"Binding /
$i
"
mkdir
-p
/rootfs/
$i
mount
--bind
/newroot/
$i
/rootfs/
$i
done
mount
--move
/sys /rootfs/kernel/sys
mount
--move
/proc /rootfs/kernel/proc
mount
--move
/dev /rootfs/kernel/dev
mount
--move
/tmp /rootfs/tmp
mount
--move
/run /rootfs/run
exec
switch_root /rootfs /sbin/init
"
$@
"
||
/busybox sh
common_boot
}
clasic_boot
(){
debug
"Mounting rootfs"
mkdir
-p
/rootfs
mount
-t
auto
$root
/newroot
mount
--move
/sys /rootfs/kernel/sys
mount
--move
/proc /rootfs/kernel/proc
mount
--move
/dev /rootfs/kernel/dev
mount
--move
/tmp /rootfs/tmp
mount
--move
/run /rootfs/run
exec
switch_root /rootfs /sbin/init
"
$@
"
||
/busybox sh
common_boot
}
if
[
"
$boot
"
==
"live"
]
;
then
msg
"Booting from live-media"
live_boot
...
...
src/scripts/99-fsswitch.sh
0 → 100644
Dosyayı görüntüle @
c668fc99
if
[
-f
/new_root/etc/os-release
]
;
then
msg
"Wellcome to
$(
cat
/new_root/etc/os-release |
grep
'^NAME='
|
head
-n
1 |
sed
's/^.*=//g'
)
"
else
msg
"Wellcome to GNU/Linux..."
fi
[
-d
"/new_root/
$subdir
"
]
||
subdir
=
"/"
debug
"Subdir=
$subdir
"
[
!
-n
$init
]
||
init
=
/sbin/init
debug
"init=
$init
"
if
[
-f
/new_root/
$subdir
/etc/initrd.local
]
;
then
msg
"Running local initrd scripts"
.
/new_root/
$subdir
/etc/initrd.local
||
true
fi
debug
"Switching root"
exec env
-i
\
"TERM=
$TERM
"
\
switch_root
"/rootfs/
$subdir
"
$init
"
$@
"
||
fallback_shell
src/vars.sh
Dosyayı görüntüle @
c668fc99
PATH
=
/bin:/usr/bin:/usr/sbin:/sbin
TERM
=
linux
rootfstype
=
ext4
C_BLACK
=
'\e[1;30m'
C_RED
=
'\e[1;31m'
C_GREEN
=
'\e[1;32m'
C_YELLOW
=
'\e[1;33m'
C_BLUE
=
'\e[1;34m'
C_PURPLE
=
'\e[1;35m'
C_CYAN
=
'\e[1;36m'
C_WHITE
=
'\e[1;37m'
C_CLEAR
=
'\e[m'
if
[
-t
0
]
;
then
C_BLACK
=
'\e[1;30m'
C_RED
=
'\e[1;31m'
C_GREEN
=
'\e[1;32m'
C_YELLOW
=
'\e[1;33m'
C_BLUE
=
'\e[1;34m'
C_PURPLE
=
'\e[1;35m'
C_CYAN
=
'\e[1;36m'
C_WHITE
=
'\e[1;37m'
C_CLEAR
=
'\e[m'
fi
msg
()
{
echo
-e
"
${
C_GREEN
}
*
${
C_CLEAR
}
${
@
}
"
}
debug
()
{
[
!
-n
"
$debug
"
]
||
echo
-e
"
${
C_BLUE
}
*
${
C_CLEAR
}
${
@
}
"
}
warn
()
{
echo
-e
"
${
C_YELLOW
}
*
${
C_CLEAR
}
${
@
}
"
}
err
()
{
echo
-e
"
${
C_RED
}
*
${
C_CLEAR
}
${
@
}
"
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment