Skip to content

Commit

Permalink
Big sync, bad but hotta push it.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasez committed Apr 10, 2016
1 parent a4b18c6 commit 00b27c8
Show file tree
Hide file tree
Showing 14 changed files with 508 additions and 32 deletions.
4 changes: 3 additions & 1 deletion configs/ffw4_raspberry_pi_defconfig
@@ -1,6 +1,6 @@
#
# Automatically generated file; DO NOT EDIT.
# Buildroot 2015.08-git-00888-gc4f0d47-dirty Configuration
# Buildroot 2015.08-git-00929-gf34db61-dirty Configuration
#
BR2_HAVE_DOT_CONFIG=y

Expand Down Expand Up @@ -204,6 +204,7 @@ BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE=y
BR2_GCC_VERSION="4.9.3"
BR2_EXTRA_GCC_CONFIG_OPTIONS=""
BR2_TOOLCHAIN_BUILDROOT_CXX=y
# BR2_TOOLCHAIN_BUILDROOT_FORTRAN is not set
BR2_GCC_ENABLE_TLS=y
# BR2_GCC_ENABLE_LTO is not set
# BR2_GCC_ENABLE_OPENMP is not set
Expand Down Expand Up @@ -713,6 +714,7 @@ BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS=y
# BR2_PACKAGE_OFONO is not set
# BR2_PACKAGE_OLA is not set
# BR2_PACKAGE_OPEN2300 is not set
# BR2_PACKAGE_OPENIPMI is not set
# BR2_PACKAGE_OPENOCD is not set

#
Expand Down
4 changes: 2 additions & 2 deletions ffw4-configs/config
Expand Up @@ -252,8 +252,8 @@ DMZ_ALLOW_FROM_INSIDE="all"
# Phone number:
TELEPHONE=

# Serial Port COM1 is /dev/tts/0, COM2 is /dev/tts/1 etc.
SERIAL_PORT=/dev/tts/1
# Serial Port COM1 is /dev/ttyS0, COM2 is /dev/ttyS1 etc.
SERIAL_PORT=/dev/ttyS1
PORT_SPEED=57600
PPP_CONNECT_TIMEOUT=60
PPP_CONNECT_POLL=3
Expand Down
2 changes: 1 addition & 1 deletion ffw4-configs/firewall.ini → ffw4-configs/firewall.init
Expand Up @@ -24,7 +24,7 @@ SERVER_IP=10.42.42.42
echo "0" > /proc/sys/net/ipv4/ip_forward

#
# Overriding the /etc/config and adding additional information.
# Overriding the /etc/ffw4.conf and adding additional information.
#
. /etc/outside.info
. /etc/inside.info
Expand Down
10 changes: 5 additions & 5 deletions ffw4-configs/network.ini → ffw4-configs/network.init
Expand Up @@ -218,18 +218,18 @@ fi
if bool_value "$DHCP_SERVER"
then
/etc/udhcpd.conf.sh
/sbin/udhcpd /etc/udhcpd.conf
pidof dnsmasq > /dev/null || /sbin/dnsmasq $DNSMASQ_OPTS
udhcpd /etc/udhcpd.conf
pidof dnsmasq > /dev/null || dnsmasq $DNSMASQ_OPTS
else
if bool_value "$DNSMASQ"
then
pidof dnsmasq > /dev/null || /sbin/dnsmasq $DNSMASQ_OPTS
pidof dnsmasq > /dev/null || dnsmasq $DNSMASQ_OPTS
fi
fi

if bool_value "$DMZ_DHCP_SERVER"
then
/etc/dmz-udhcpd.conf.sh
/sbin/udhcpd /etc/dmz-udhcpd.conf
pidof dnsmasq > /dev/null || /sbin/dnsmasq $DNSMASQ_OPTS
udhcpd /etc/dmz-udhcpd.conf
pidof dnsmasq > /dev/null || dnsmasq $DNSMASQ_OPTS
fi
4 changes: 4 additions & 0 deletions scripts/mk_rpi_sdcard.sh
Expand Up @@ -163,7 +163,11 @@ ${CP} ${OUTPUT_PREFIX}images/rpi-firmware/start.elf .mnt
${CP} ${OUTPUT_PREFIX}images/zImage .mnt/kernel.img
${CP} ${OUTPUT_PREFIX}images/*txt .mnt
${CP} ffw4-configs/* .mnt
[ -f ffw4-configs/rpi_cmdline.txt ] && ${CP} ffw4-configs/rpi_cmdline.txt .mnt/cmdline.txt
[ -f ffw4-configs/rpi_config.txt ] && ${CP} ffw4-configs/rpi_config.txt .mnt/config.txt
${CP} local-configs/* .mnt
[ -f local-configs/rpi_cmdline.txt ] && ${CP} local-configs/rpi_cmdline.txt .mnt/cmdline.txt
[ -f local-configs/rpi_config.txt ] && ${CP} local-configs/rpi_config.txt .mnt/config.txt
${SYNC}
${UMOUNT} .mnt

Expand Down
188 changes: 188 additions & 0 deletions scripts/mksdcard_pi
@@ -0,0 +1,188 @@
#!/bin/sh
#
# Flash Raspberry Pi SD card [buildroot]
#
# Guillermo A. Amaral B. <g@maral.me>
#

SDCARD="${1}"

usage() {
echo "Usage: ${0} [SDCARD]"
echo "Where SDCARD is your SD card device node, for example: /dev/sdx"
echo
echo "You will require *root* privileges in order to use this script."
echo
}

confirm() {
echo "You are about to totally decimate the following device node: ${SDCARD}"
echo
echo "If you are sure you want to continue? (Please write \"YES\" in all caps)"

read CONTUNUE

if [ "${CONTUNUE}" != "YES" ]; then
echo "User didn't write \"YES\"... ABORTING!"
exit 1
fi
}

section() {
echo "*****************************************************************************************"
echo "> ${*}"
echo "*****************************************************************************************"
sleep 1
}

# environment overrides

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
OUTPUT_PREFIX=""

# check parameters

if [ -z "${SDCARD}" ] || [ "${SDCARD}" = "-h" ] || [ "${SDCARD}" = "--help" ]; then
usage
exit 0
fi

# check if node is a block device

if [ ! -b "${SDCARD}" ]; then
echo "${SDCARD} is not a block device!"
exit 1
fi

# root privilege check

USERID=`id -u`
if [ ${USERID} -ne 0 ]; then
echo "${0} requires root privileges in order to work."
exit 0
fi

# dependencies

CP=`which cp`
FDISK=`which fdisk`
MKDIR=`which mkdir`
MKFS_EXT4=`which mkfs.ext4`
MKFS_VFAT=`which mkfs.vfat`
MOUNT=`which mount`
RMDIR=`which rmdir`
SYNC=`which sync`
TAR=`which tar`
UMOUNT=`which umount`

if [ -z "${CP}" ] ||
[ -z "${FDISK}" ] ||
[ -z "${MKDIR}" ] ||
[ -z "${MKFS_EXT4}" ] ||
[ -z "${MKFS_VFAT}" ] ||
[ -z "${MOUNT}" ] ||
[ -z "${RMDIR}" ] ||
[ -z "${TAR}" ] ||
[ -z "${UMOUNT}" ]; then
echo "Missing dependencies:\n"
echo "CP=${CP}"
echo "FDISK=${FDISK}"
echo "MKDIR=${MKDIR}"
echo "MKFS_EXT4=${MKFS_EXT4}"
echo "MKFS_VFAT=${MKFS_VFAT}"
echo "MOUNT=${MOUNT}"
echo "RMDIR=${RMDIR}"
echo "TAR=${TAR}"
echo "UMOUNT=${UMOUNT}"
exit 1
fi

# sanity check

if [ ! -d "images/rpi-firmware" ] || [ ! -f "images/rootfs.tar" ]; then
if [ -d "output/images/rpi-firmware" ] && [ -f "output/images/rootfs.tar" ]; then
OUTPUT_PREFIX="output/"
else
echo "Didn't find rpi-firmware and/or rootfs.tar! ABORT."
exit 1
fi
fi

# warn user

confirm

# partition image

section "Partitioning SD card..."

${FDISK} ${SDCARD} <<END
o
n
p
1
+32M
n
p
2
t
1
e
a
1
w
END

sleep 1

# figure out partition pattern

case "${SDCARD}" in
*mmcblk*) SDCARDP="${SDCARD}p" ;;
*) SDCARDP="${SDCARD}" ;;
esac

# format partitions

section "Formatting partitions..."

${MKFS_VFAT} -F 16 -n BOOT -I "${SDCARDP}1" || exit 1
${MKFS_EXT4} -F -q -L rootfs "${SDCARDP}2" || exit 1


# prepare to fill partitions

${MKDIR} .mnt

# fill boot

section "Populating boot partition..."
${MOUNT} "${SDCARDP}1" .mnt || exit 2

${CP} ${OUTPUT_PREFIX}images/rpi-firmware/bootcode.bin .mnt
${CP} ${OUTPUT_PREFIX}images/rpi-firmware/fixup.dat .mnt
${CP} ${OUTPUT_PREFIX}images/rpi-firmware/start.elf .mnt
${CP} ${OUTPUT_PREFIX}images/zImage .mnt/kernel.img
${CP} ${OUTPUT_PREFIX}images/*.dtb .mnt
${SYNC}
${UMOUNT} .mnt

# fill rootfs

section "Populating rootfs partition..."
${MOUNT} "${SDCARDP}2" .mnt || exit 2

${TAR} -xpsf ${OUTPUT_PREFIX}images/rootfs.tar -C .mnt
${SYNC}
${UMOUNT} .mnt

# clean up

${RMDIR} .mnt

section "Finished!"

exit 0
2 changes: 1 addition & 1 deletion skeleton/etc/dmz-udhcpd.conf.sh
Expand Up @@ -2,7 +2,7 @@

# $Id:$

. /etc/vmfw.conf
. /etc/ffw4.conf
. /etc/dmz.info

if [ "$DMZ_DOMAIN" ]
Expand Down
33 changes: 15 additions & 18 deletions skeleton/etc/init.d/S01copyconfigs
Expand Up @@ -17,22 +17,15 @@ if [ "$1" != "start" -a "$1" != "restart" ]
fi

COMMAND_LINE=`cat /proc/cmdline`
echo -e COMMAND_LINE=\"$COMMAND_LINE\" >> /etc/ffw4.conf

ROOTDEV=$(echo $COMMAND_LINE |sed -e 's/$/ /' -e 's/.*root=\([^ ]*\) .*/\1/' -e 's/,/ /g' -e 's:/dev/nfs:/dev/fd0:')

if echo $COMMAND_LINE | grep configdevice
then
echo Setting configdevice
CONFDEV=$(echo $COMMAND_LINE | sed -e 's/$/ /' -e 's/.*configdevice=\([^ ]*\) .*/\1/' -e 's/,/ /g' -e 's:/dev/nfs:/dev/fd0:')
echo set to $CONFDEV
fi

# If no set config device, set root device and exit this script.
if [ -z "$CONFDEV" ]
then
echo "SOURCE_DEV=$ROOTDEV" >> /etc/ffw4.conf
exit 0
else
# I presume the files are named correctly in the root file system.
exit 0
fi

echo $CONFDEV > /etc/ffw4.confdevice
Expand Down Expand Up @@ -61,7 +54,7 @@ do
shift; shift
done

CONFIG_FILES="dmz-ethers.ini dmz-fw.ini ffw4.conf config ethers hosts modules.lst firewall.ini network.ini"
CONFIG_FILES="dmz-ethers.ini dmz-fw.ini ffw4.conf config ethers hosts modules.lst firewall.ini network.ini firewall.init network.init"

for cf in $CONFIG_FILES
do
Expand All @@ -72,16 +65,20 @@ for cf in $CONFIG_FILES
fi
done

for fwf in /mnt/config/*-fw.ini*
do
if [ -f /mnt/config/$fwf ]
then
stripcr /mnt/config/$fwf /etc/firewall/$fwf
echo "Stripped and copied $fwf"
fi
done

# I want real nice names.
[ -f /etc/config ] && mv /etc/config /etc/ffw4.conf
mv /etc/network.ini /etc/network.init
[ -f /etc/network.ini ] && mv /etc/network.ini /etc/network.init
chmod 755 /etc/network.init
mv /etc/firewall.ini /etc/firewall.init
[ -f /etc/firewall.ini ] && mv /etc/firewall.ini /etc/firewall.init
chmod 755 /etc/firewall.init
stripcr /mnt/tmp/floppyfw.msg /etc/issue 644

# I also want to add the source device and file system so that I can remount.
set -- $ROOTDEV
echo "SOURCE_DEV=$ROOTDEV" >> /etc/ffw4.conf
echo "CONFIG_DEV=$CONFDEV" >> /etc/ffw4.conf

6 changes: 4 additions & 2 deletions skeleton/etc/init.d/S03password
Expand Up @@ -16,6 +16,7 @@ echo "Setting password for root"

#
# The file to play with.
# TODO: Check if we are using /etc/shadow or not..
#
PW_F=/etc/passwd

Expand All @@ -25,8 +26,9 @@ if [ "$PASSWORD" != "" ]
fi

# Right now, all we do it handle the DES_PASSWORD correctly:
sed -i -e "s|^root:x:|root:$DES_PASSWORD:|" $PW_F
sed -i -e "s|^root:x:|root:$DES_PASSWORD:|" /etc/shadow
# (sed seems not to like x? which is why I use x* although there is only one x
sed -i -e "s|^root:x*:|root:$DES_PASSWORD:|" $PW_F
sed -i -e "s|^root:x*:|root:$DES_PASSWORD:|" /etc/shadow

sed -i -e "s:^PASSWORD.*::" /etc/ffw4.conf

4 changes: 2 additions & 2 deletions skeleton/etc/udhcpc.sh
Expand Up @@ -23,7 +23,7 @@ if $(bool_value "$DHCP_USE_LAST_ADDR" && [ -f /etc/dhcp.addr ])
if [ "$LAST_DHCP_ADDR" != "" ]
then
echo "Gonna ask for $LAST_DHCP_ADDR"
if /sbin/udhcpc -t 3 -r $LAST_DHCP_ADDR -n -s /etc/udhcpcrenew.sh $HARGS -i $OUTSIDE_DEV
if udhcpc -t 3 -r $LAST_DHCP_ADDR -n -s /etc/udhcpcrenew.sh $HARGS -i $OUTSIDE_DEV
then
. /etc/outside.info
echo $OUTSIDE_IP > /etc/dhcp.addr 2> /dev/null
Expand All @@ -36,7 +36,7 @@ fi
#
# OK, either we did not have an existing address or we did not get it.
#
if /sbin/udhcpc -n -s /etc/udhcpcrenew.sh $HARGS -i $OUTSIDE_DEV
if udhcpc -n -s /etc/udhcpcrenew.sh $HARGS -i $OUTSIDE_DEV
then
if $(bool_value "$DHCP_USE_LAST_ADDR" && touch /etc/dhcp.addr 2> /dev/null)
then
Expand Down

0 comments on commit 00b27c8

Please sign in to comment.