Skip to content

Commit ec0ae60

Browse files
committed
add startup files for bb services
1 parent 68fc94c commit ec0ae60

10 files changed

+155
-14
lines changed

LICENSE.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2014 Mattias Schlenker
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ So to build TinyCrossLinux run
2929

3030
## FAQ
3131

32+
### Start services
33+
34+
Currently the following services provided by BusyBox or dropbearmulti are available. They are inactive by default, so use the bootparameters specified to enable them:
35+
36+
* SSHD `sshd=1` - you might want to add a permanent key to `/etc/dropbear`
37+
* HTTPD `httpd=1` - searches for files in `/srv/www`
38+
* TFTPD `tftpd=1` - serves files from `/srv/tftp`
39+
* UDHCPD `udhcpd=1` - starts only in `/etc/udhcpd.conf` is present
40+
3241
### Login with password?
3342

3443
Run the command
@@ -53,13 +62,7 @@ The build script `stage02/0001_basefiles.sh` installs some of the startup script
5362

5463
### Do you plan to add features?
5564

56-
This linux distribution will stay small and compact, thus I do not plan to add many features. I will add some startup scripts that you can install by extending or adding scripts in stage02 to install them. This will include examples for services provided by BusyBox:
57-
58-
* httpd
59-
* tftpd
60-
* udhcpd
61-
62-
Those together are enough to build a PXE boot server. I also will add some build scripts to further expand the system for some rescue and forensic purposes:
65+
This linux distribution will stay small and compact, thus I do not plan to add many features. I will add some build scripts to further expand the system for some rescue and forensic purposes:
6366

6467
* ddrescue
6568
* ntfs-3g (ntfsclone etc.)

patches/etc-rc

+2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ mkdir -p /dev/pts
1313
mkdir -p /dev/shm
1414
mkdir -p /dev/mapper
1515
mkdir -p /sys
16+
mkdir /tmp
1617
mountpoint -q /sys || mount -t sysfs sysfs /sys
1718
mountpoint -q /dev/pts || mount -t devpts -o rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 devpts /dev/pts
1819
mountpoint -q /dev/shm || mount -t tmpfs devshm /dev/shm
20+
mountpoint -q /tmp || mount -t tmpfs tmpfs /tmp
1921

2022
for i in /etc/rc.d/[0-9][0-9][0-9][0-9]-*.?? ; do
2123
$i start

patches/etc-rc.d-0020-loadmodules.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ case $1 in
4848
modprobe -q -b $modname
4949
alreadyloaded="$alreadyloaded $modname "
5050
fi
51-
done
51+
done
5252
mountpoint -q /proc/bus/usb || mount -t usbfs usbfs /proc/bus/usb
5353
mdev -s
5454
printf "${bold}Loading USB drivers ${success} ${normal}\n"
55+
printf "${bold}Loading MISC drivers... ${normal}\n"
56+
for n in sd_mod sg usb_storage ; do
57+
modprobe $n
58+
done
5559
;;
5660
esac

patches/etc-rc.d-0050-dropbear.sh

+14-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,20 @@ export PATH
66

77
case $1 in
88
start)
9-
printf "${bold}Starting dropbear SSHD... ${normal}"
10-
for t in ecdsa ; do # ignore rsa dss
11-
[ -f /etc/dropbear/dropbear_${t}_host_key ] || dropbearkey -t ${t} -f /etc/dropbear/dropbear_${t}_host_key
9+
enable=0
10+
for tok in ` cat /proc/cmdline ` ; do
11+
case $tok in
12+
dropbear=1)
13+
enable=1
14+
;;
15+
esac
1216
done
13-
dropbear && printf "${bold}Starting dropbear SSHD ${success}\n" || printf "${bold}Starting dropbear SSHD ${failed}\n"
17+
if [ "$enable" -gt 0 ] ; then
18+
printf "${bold}Starting dropbear SSHD... ${normal}"
19+
for t in ecdsa ; do # ignore rsa dss
20+
[ -f /etc/dropbear/dropbear_${t}_host_key ] || dropbearkey -t ${t} -f /etc/dropbear/dropbear_${t}_host_key
21+
done
22+
dropbear && printf "${bold}Starting dropbear SSHD ${success}\n" || printf "${bold}Starting dropbear SSHD ${failed}\n"
23+
fi
1424
;;
1525
esac

patches/etc-rc.d-0055-httpd.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/ash
2+
3+
PATH=/bin:/sbin:/usr/bin:/usr/sbin
4+
source /etc/rc.subr/colors
5+
export PATH
6+
7+
case $1 in
8+
start)
9+
enable=0
10+
for tok in ` cat /proc/cmdline ` ; do
11+
case $tok in
12+
'httpd=1')
13+
enable=1
14+
;;
15+
esac
16+
done
17+
if [ "$enable" -gt 0 ] ; then
18+
printf "${bold}Starting HTTPD ${normal}"
19+
if [ -d /srv/www ] ; then
20+
echo "Using existing /srv/www"
21+
else
22+
mkdir -p /srv/www
23+
echo '<html><body>Hello World</body></html>' > /srv/www/index.html
24+
fi
25+
httpd -h /srv/www && printf "${success}\n" || printf "${failed}\n"
26+
fi
27+
;;
28+
stop)
29+
killall -9 httpd
30+
;;
31+
esac

patches/etc-rc.d-0060-tftpd.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/ash
2+
3+
PATH=/bin:/sbin:/usr/bin:/usr/sbin
4+
source /etc/rc.subr/colors
5+
export PATH
6+
7+
case $1 in
8+
start)
9+
enable=0
10+
for tok in ` cat /proc/cmdline ` ; do
11+
case $tok in
12+
tftpd=1)
13+
enable=1
14+
;;
15+
esac
16+
done
17+
if [ "$enable" -gt 0 ] ; then
18+
printf "${bold}Starting TFPD... ${normal}\n"
19+
if [ -d /srv/tftp ] ; then
20+
echo "Using existing /srv/tftp"
21+
else
22+
mkdir -p /srv/tftp
23+
echo 'Hello World' > /srv/tftp/test.txt
24+
fi
25+
udpsvd -E 0 69 tftpd -l /srv/tftp &
26+
fi
27+
;;
28+
stop)
29+
killall -9 udpsvd
30+
;;
31+
esac

patches/etc-rc.d-0065-udhcpd.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/ash
2+
3+
PATH=/bin:/sbin:/usr/bin:/usr/sbin
4+
source /etc/rc.subr/colors
5+
export PATH
6+
7+
case $1 in
8+
start)
9+
enable=0
10+
for tok in ` cat /proc/cmdline ` ; do
11+
case $tok in
12+
udhcpd=1)
13+
enable=1
14+
;;
15+
esac
16+
done
17+
if [ "$enable" -gt 0 ] ; then
18+
printf "${bold}Starting UDHCPD ${normal}"
19+
if [ -f /etc/udhcpd.conf ] ; then
20+
udhcpd /etc/udhcpd.conf && printf "${success}\n" || printf "${failed}\n"
21+
else
22+
printf ": /etc/udhcpd.conf missing ${failed}\n"
23+
fi
24+
fi
25+
;;
26+
stop)
27+
killall -9 udhcpd
28+
;;
29+
esac

patches/help.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
Welcome to TinyCrossLinux - Mattias Schlenkers lesson to teach how to
3+
construct a really compact distribution running from initramfs.
4+
5+
Please consult https://github.com/mschlenker/TinyCrossLinux
6+
to obtain the build scripts and further information!
7+
8+
Have fun!

stage02/0001_basefiles.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ source stage01_variables
33
source stage02_variables
44

55
PKGNAME=basefiles
6-
PKGVERSION=20140715
6+
PKGVERSION=20140716
77

88
# Build and install
9-
109
mkdir -p ${CLFS}/targetfs/etc/rc.d
1110
mkdir -p ${CLFS}/targetfs/etc/rc.subr
1211
mkdir -p ${CLFS}/targetfs/root
@@ -33,3 +32,8 @@ install -m 0755 patches/etc-rc.d-0010-loop.sh ${CLFS}/targetfs/etc/rc.d/0010-loo
3332
install -m 0755 patches/etc-rc.d-0012-syslogd.sh ${CLFS}/targetfs/etc/rc.d/0012-syslogd.sh
3433
install -m 0755 patches/etc-rc.d-0020-loadmodules.sh ${CLFS}/targetfs/etc/rc.d/0020-loadmodules.sh
3534
install -m 0755 patches/etc-rc.d-0040-udhcpd.sh ${CLFS}/targetfs/etc/rc.d/0040-udhcpc.sh
35+
36+
# optional startup scripts
37+
install -m 0755 patches/etc-rc.d-0055-httpd.sh ${CLFS}/targetfs/etc/rc.d/0055-httpd.sh
38+
install -m 0755 patches/etc-rc.d-0060-tftpd.sh ${CLFS}/targetfs/etc/rc.d/0060-tftpd.sh
39+
install -m 0755 patches/etc-rc.d-0065-udhcpd.sh ${CLFS}/targetfs/etc/rc.d/0060-udhcpd.sh

0 commit comments

Comments
 (0)