rootfs cleanups - added fs/network init, syslogd, telnetd, serial console, dhcp client
This commit is contained in:
parent
dc7829405f
commit
5fb9750a37
7
Makefile
7
Makefile
@ -14,7 +14,12 @@ all: kernel-axe-modules kernel
|
||||
#
|
||||
|
||||
fs.cpio:
|
||||
fakeroot tools/do_min_fs.py
|
||||
fakeroot tools/do_min_fs.py \
|
||||
-b bash
|
||||
|
||||
.PHONY: fs-list
|
||||
fs-list:
|
||||
cpio -itv < kernel/rootfs-idl4k.cpio
|
||||
|
||||
#
|
||||
# kernel
|
||||
|
3
fs-add/etc/bashrc
Normal file
3
fs-add/etc/bashrc
Normal file
@ -0,0 +1,3 @@
|
||||
# /etc/bashrc
|
||||
|
||||
test "$PS1" = "\\s-\\v\\\$ " && PS1="[\u@\h \W]\\$ "
|
41
fs-add/etc/init.d/dhcpc-event
Executable file
41
fs-add/etc/init.d/dhcpc-event
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
test -z "$1" && echo "Error: should be called from udhcpc" && exit 1
|
||||
|
||||
RESOLV_CONF="/etc/resolv.conf"
|
||||
test -n "$broadcast" && BROADCAST="broadcast $broadcast"
|
||||
test -n "$subnet" && NETMASK="netmask $subnet"
|
||||
|
||||
case "$1" in
|
||||
deconfig)
|
||||
grep -q -v ip= /proc/cmdline
|
||||
if test $? -eq 0; then
|
||||
/sbin/ifconfig $interface up
|
||||
fi
|
||||
grep -q -v nfsroot= /proc/cmdline
|
||||
if test $? -eq 0; then
|
||||
/sbin/ifconfig $interface 0.0.0.0
|
||||
fi
|
||||
;;
|
||||
leasefail|nak)
|
||||
;;
|
||||
renew|bound)
|
||||
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
|
||||
if test -n "$router" ; then
|
||||
echo "deleting routers"
|
||||
while route del default gw 0.0.0.0 dev $interface ; do
|
||||
:
|
||||
done
|
||||
for i in $router ; do
|
||||
route add default gw $i dev $interface
|
||||
done
|
||||
fi
|
||||
echo -n > $RESOLV_CONF
|
||||
test -n "$domain" && echo "search $domain" >> $RESOLV_CONF
|
||||
for i in $dns ; do
|
||||
echo "adding dns $i"
|
||||
echo "nameserver $i" >> $RESOLV_CONF
|
||||
done
|
||||
;;
|
||||
esac
|
||||
exit 0
|
32
fs-add/etc/init.d/rcSBB
Executable file
32
fs-add/etc/init.d/rcSBB
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/busybox sh
|
||||
|
||||
busybox echo "Welcome to SATIP-AXE Linux!"
|
||||
|
||||
busybox mount -t proc proc /proc
|
||||
# remount root filesystem in rw mode
|
||||
busybox mount -o remount,rw /
|
||||
# Create all symbolic links.
|
||||
/bin/busybox --install -s
|
||||
|
||||
# mount /dev and devpts to allow logging in
|
||||
mount -t tmpfs -o size=64k,mode=0755 tmpfs /dev
|
||||
mkdir /dev/pts /dev/input
|
||||
mount -t devpts none /dev/pts -ogid=5,mode=620
|
||||
|
||||
# use mdev/sysfs
|
||||
mount -t sysfs sysfs /sys
|
||||
echo /sbin/mdev > /proc/sys/kernel/hotplug
|
||||
echo /sbin/hotplug > /proc/sys/kernel/hotplug
|
||||
mdev -s
|
||||
|
||||
# make /tmp as tmpfs
|
||||
mount -t tmpfs -o size=1M tmpfs /tmp
|
||||
|
||||
# start syslogd
|
||||
syslogd -C256
|
||||
|
||||
# basic network
|
||||
hostname satip-axe
|
||||
ifconfig lo 127.0.0.1 netmask 255.255.255.0
|
||||
ifconfig eth0 up
|
||||
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
|
13
fs-add/etc/inittabBB
Executable file
13
fs-add/etc/inittabBB
Executable file
@ -0,0 +1,13 @@
|
||||
# Boot
|
||||
::sysinit:/etc/init.d/rcSBB
|
||||
# Console
|
||||
ttyAS0::askfirst:/bin/bash --init-file /etc/bashrc
|
||||
# DHCP Client
|
||||
::respawn:/sbin/udhcpc -f -S -p /tmp/udhcpc.pid -s /etc/init.d/dhcpc-event
|
||||
# telnetd
|
||||
::respawn:/usr/sbin/telnetd -F -l /bin/login
|
||||
# Others
|
||||
::ctrlaltdel:/sbin/reboot
|
||||
::shutdown:/sbin/swapoff -a
|
||||
::shutdown:/bin/umount -a -r
|
||||
::restart:/sbin/init
|
2
fs-add/etc/motd
Normal file
2
fs-add/etc/motd
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
Welcome to SATIP-AXE server
|
26
fs-add/etc/passwd
Normal file
26
fs-add/etc/passwd
Normal file
@ -0,0 +1,26 @@
|
||||
root:KelgCamVIiREw:0:0:root:/root:/bin/sh
|
||||
bin:*:1:1:bin:/bin:
|
||||
daemon:*:2:2:daemon:/usr/sbin:
|
||||
sys:*:3:3:sys:/dev:
|
||||
adm:*:4:4:adm:/var/adm:
|
||||
lp:*:5:7:lp:/var/spool/lpd:
|
||||
sync:*:6:8:sync:/bin:/bin/sync
|
||||
shutdown:*:7:9:shutdown:/sbin:/sbin/shutdown
|
||||
halt:*:8:10:halt:/sbin:/sbin/halt
|
||||
mail:*:9:11:mail:/var/spool/mail:
|
||||
news:*:10:12:news:/var/spool/news:
|
||||
operator:*:12:0:operator:/root:
|
||||
games:*:13:100:games:/usr/games:
|
||||
ftp:*:15:14:ftp:/var/ftp:
|
||||
man:*:16:100:man:/var/cache/man:
|
||||
nobody:*:65534:65534:nobody:/home:/bin/sh
|
||||
dbus:*:81:81:System message bus:/:/sbin/nologin
|
||||
avahi:*:76:76:avahi:/var/lib/misc:/bin/false
|
||||
rpc:*:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
|
||||
sshd:*:74:74:sshd:/var/empty/sshd:/bin/false
|
||||
ntp:*:38:38:ntp:/etc/ntp:/sbin/nologin
|
||||
httpd:*:75:75:httpd:/home/httpd:/bin/false
|
||||
dnsmasq:*:75:75:dnsmasq:/var/lib/misc:/bin/false
|
||||
rtpproxy:*:492:484:rtpproxy:/home/rtpproxy:/bin/false
|
||||
npd6:*:86:86:npd6 user:/:/sbin/nologin
|
||||
radvd:*:85:85:radvd user:/:/sbin/nologin
|
@ -11,6 +11,7 @@ def run_cmd(cmd):
|
||||
You can use the builtin 'command' module.
|
||||
Like: command.getoutput()
|
||||
"""
|
||||
print cmd
|
||||
try:
|
||||
cmd = str(cmd) + ' > output.txt'
|
||||
# print 'command: ' + cmd
|
||||
@ -167,42 +168,11 @@ def del_line_feed(my_list):
|
||||
#---------------------------------------
|
||||
|
||||
def setup_busybox():
|
||||
cmd = 'cp ' + target_prefix + '/bin/busybox fs/bin'
|
||||
run_cmd(cmd)
|
||||
busybox_cmds = ['sh', 'ls', 'echo', 'mount', 'umount', 'pwd', 'mv', 'cp', 'rm', 'ln', \
|
||||
'mkdir', 'vi', 'cat', 'halt']
|
||||
for a in busybox_cmds:
|
||||
cmd = ' ln -s /bin/busybox fs/bin/' + str(a)
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
run_cmd('cp ' + target_prefix + '/bin/busybox fs/bin')
|
||||
|
||||
cmd = 'ln -s /bin/busybox fs/sbin/init'
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
cmd = 'ln -s /sbin/init fs/init'
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
|
||||
# init.d/rcS
|
||||
fd = open('fs/etc/init.d/rcS', 'wr')
|
||||
fd.write('#!/bin/bash\n echo "Welcome to a custom minimal file system"\n mount -t proc proc /proc\n mount -o remount,noatime /dev/root /')
|
||||
fd.close()
|
||||
cmd = ' chmod a+x fs/etc/init.d/rcS '
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
|
||||
# init.d/rcSBB
|
||||
fd2 = open('fs/etc/init.d/rcSBB', 'wr')
|
||||
# fd2.write('#!/bin/sh\n # example rcS script\n echo "Welcome to STLinux!"\n mount -t proc proc /proc\n mount -n -o remount,rw /\n mount -t devpts none /dev/pts -ogid=5,mode=620\n /usr/sbin/telnetd -l /bin/sh')
|
||||
fd2.write('#!/bin/sh\n # example rcS script\n echo "Welcome to STLinux!"\n mount -t proc proc /proc\n mount -n -o remount,rw /\n mount -t devpts none /dev/pts -ogid=5,mode=620\n /bin/sh')
|
||||
fd2.close()
|
||||
cmd = ' chmod a+x fs/etc/init.d/rcSBB '
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
|
||||
cmd = ' chmod a+x fs/etc/init.d/rcSBB '
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
run_cmd(' ln -s /bin/busybox fs/sbin/init')
|
||||
run_cmd(' ln -s /bin/busybox fs/init')
|
||||
run_cmd(' ln -s /bin/busybox fs/bin/sh')
|
||||
|
||||
#-----------------------------------------------
|
||||
|
||||
@ -210,13 +180,10 @@ def setup_sysvinit():
|
||||
print 'setup_sysvinit target_prefix ' + str(target_prefix)
|
||||
bin = ['/usr/bin/passwd', '/bin/egrep']
|
||||
for j in bin:
|
||||
cmd = 'cp ' + target_prefix + j + ' fs' + j
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
run_cmd('cp ' + target_prefix + j + ' fs' + j)
|
||||
|
||||
# link sh --> bash
|
||||
cmd = ' cd fs/bin; ln -s bash sh'
|
||||
get_cmd_output(cmd)
|
||||
run_cmd(' cd fs/bin; ln -s bash sh')
|
||||
|
||||
# run_cmd('cp -a ' + target_prefix + '/etc/inittab' + ' fs/etc/')
|
||||
# run_cmd('cp -a ' + target_prefix + '/etc/inittabBB' + ' fs/etc/')
|
||||
@ -264,37 +231,10 @@ def setup_sysvinit():
|
||||
#cmd = ' cd fs/etc/rc.d/; ln -s ../init.d init.d'
|
||||
#get_cmd_output(cmd)
|
||||
|
||||
cmd = ' chmod a+x fs/lib/* '
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
|
||||
cmd = ' chmod a+x fs/usr/lib/* '
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
|
||||
cmd = 'cp -d ' + target_prefix + '/usr/lib/libwrap*' + ' fs/usr/lib/'
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
cmd = 'cp -d ' + target_prefix + 'lib/libnsl*' + ' fs/usr/lib/'
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
|
||||
#------------------------------------------------
|
||||
|
||||
def make_dev():
|
||||
device_list = ['console c 5 1 ' , 'null c 1 3 ', 'fb0 c 29 0 ', 'fbcondecor c 10 63 ', \
|
||||
'ram0 b 1 0 ', 'ram1 b 1 1 ', 'ram2 b 1 2 ', 'ram3 b 1 3 ', 'ram4 b 1 4 ', 'ram5 b 1 5 ', \
|
||||
'ram6 b 1 6 ', 'ram7 b 1 7 ', 'ram8 b 1 8 ', 'ram9 b 1 9 ', 'ram10 b 1 10 ', 'ram11 b 1 11 ', \
|
||||
'ram12 b 1 12 ', 'ram13 b 1 13 ', 'ram14 b 1 14 ', 'ram15 b 1 15 ', 'ram16 b 1 16 ', \
|
||||
'rtc c 10 135 ', 'sda1 b 8 1 ', 'timer c 116 33 ', 'tty c 5 0 ', 'tty0 c 4 0 ', \
|
||||
'tty1 c 4 1 ', 'tty2 c 4 2 ', 'tty10 c 4 10 ', 'tty16 c 4 16 ']
|
||||
|
||||
for i in device_list:
|
||||
cmd = 'mknod fs/dev/' + i
|
||||
print cmd
|
||||
run_cmd(cmd)
|
||||
|
||||
run_cmd(' ln -s ram1 fs/dev/ram ')
|
||||
run_cmd(' chmod a+x fs/lib/* ')
|
||||
run_cmd(' chmod a+x fs/usr/lib/* ')
|
||||
run_cmd('cp -d ' + target_prefix + '/usr/lib/libwrap*' + ' fs/usr/lib/')
|
||||
run_cmd('cp -d ' + target_prefix + 'lib/libnsl*' + ' fs/usr/lib/')
|
||||
|
||||
#------------------------------------------------
|
||||
|
||||
@ -305,15 +245,10 @@ def gen_fs(lib_list, init_type):
|
||||
"""
|
||||
print '\t coping libraries and binary files \n'
|
||||
run_cmd('rm -rf fs fs.cpio')
|
||||
run_cmd('mkdir -p fs/sbin')
|
||||
run_cmd('mkdir -p fs/bin')
|
||||
run_cmd('mkdir -p fs/dev')
|
||||
run_cmd('mkdir -p fs/etc')
|
||||
run_cmd('mkdir -p fs/lib')
|
||||
run_cmd('mkdir -p fs/tmp')
|
||||
run_cmd('mkdir -p fs/proc')
|
||||
run_cmd('mkdir -p fs/usr')
|
||||
run_cmd('mkdir -p fs/var')
|
||||
for i in ['sbin', 'bin', 'dev', 'sys', 'etc', 'lib', 'tmp', 'proc', 'usr', 'var', 'root']:
|
||||
run_cmd('mkdir -p fs/' + i)
|
||||
for i in ['sbin', 'bin']:
|
||||
run_cmd('mkdir -p fs/usr/' + i)
|
||||
|
||||
|
||||
for i in lib_list:
|
||||
@ -324,12 +259,10 @@ def gen_fs(lib_list, init_type):
|
||||
fs_dir = target_dir.replace(target_prefix, '')
|
||||
run_cmd('mkdir -p ' + 'fs/' + fs_dir)
|
||||
run_cmd('cp -a ' + i + ' fs/' + fs_dir)
|
||||
print 'cp -a ' + i + ' fs/' + fs_dir
|
||||
if (target_dir.find('/bin') >=0):
|
||||
fs_dir = target_dir.replace(target_prefix, '')
|
||||
run_cmd('mkdir -p ' + 'fs/' + fs_dir)
|
||||
run_cmd('cp -a ' + i + ' fs/' + fs_dir)
|
||||
#run_cmd('cp ' + i + ' fs/' + fs_dir)
|
||||
if (target_dir.find('/dev') >=0):
|
||||
fs_dir = target_dir.replace(target_prefix, '')
|
||||
run_cmd('mkdir -p ' + 'fs/' + fs_dir)
|
||||
@ -351,35 +284,21 @@ def gen_fs(lib_list, init_type):
|
||||
#print cmd
|
||||
#run_cmd(cmd)
|
||||
|
||||
cmd = ' cp ' + target_prefix + '/etc/{passwd,group,hosts} fs/etc '
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
run_cmd(' cp ' + target_prefix + '/etc/{passwd,group,hosts} fs/etc ')
|
||||
|
||||
make_dev()
|
||||
|
||||
cmd = ' chmod a+x fs/lib/lib* '
|
||||
run_cmd(cmd)
|
||||
cmd = ' chmod a+x fs/etc/* '
|
||||
run_cmd(cmd)
|
||||
run_cmd(' chmod a+x fs/lib/lib* ')
|
||||
run_cmd(' chmod a+x fs/etc/* ')
|
||||
|
||||
print '\t====== coping additional libs ========'
|
||||
# libnss_* are required from login; but it's not possible get by ldd cmd
|
||||
cmd = 'cp -d ' + target_prefix + '/lib/libnss*' + ' fs/lib/'
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
cmd = 'cp -d ' + target_prefix + '/lib/libnss_nis*' + ' fs/lib/'
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
cmd = 'cp -d ' + target_prefix + '/lib/libnss_nisplus*' + ' fs/lib/'
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
run_cmd('cp -d ' + target_prefix + '/lib/libnss*' + ' fs/lib/')
|
||||
run_cmd('cp -d ' + target_prefix + '/lib/libnss_nis*' + ' fs/lib/')
|
||||
run_cmd('cp -d ' + target_prefix + '/lib/libnss_nisplus*' + ' fs/lib/')
|
||||
|
||||
# libgcc_s.so.1 is reqired from libpthread but it's not possible get it by ldd cmd
|
||||
for i in lib_list:
|
||||
if i.find('libpthread') >= 0:
|
||||
cmd = 'cp -a ' + target_prefix + '/lib/libgcc_*' + ' fs/lib/'
|
||||
run_cmd(cmd)
|
||||
print cmd
|
||||
run_cmd('cp -a ' + target_prefix + '/lib/libgcc_*' + ' fs/lib/')
|
||||
print '\t======================================='
|
||||
|
||||
if init_type == 'busybox':
|
||||
@ -550,7 +469,6 @@ def get_common_path(s1, s2):
|
||||
com = str(com) + '*'
|
||||
return com
|
||||
|
||||
|
||||
## ================================================================
|
||||
## Main
|
||||
## =================================================================
|
||||
@ -626,4 +544,11 @@ for j in library_list:
|
||||
print ' ' + 30*'=' + '\n'
|
||||
|
||||
gen_fs(library_list, boot_type)
|
||||
run_cmd('cp -av fs-add/* fs')
|
||||
files = run_cmd('find fs -name "*~"')
|
||||
for f in files:
|
||||
run_cmd('rm ' + f.strip())
|
||||
for r in ['usr/bin/bashbug']:
|
||||
if os.path.exists('fs/' + r):
|
||||
run_cmd('rm fs/' + r)
|
||||
do_cpio('fs')
|
||||
|
Loading…
Reference in New Issue
Block a user