From d956c803890acd0c5023a5940e398775fb5d46ca Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Fri, 07 Jun 2024 00:51:26 +0800 Subject: [PATCH] update image build shell script to modify profile and sshd service --- images/build.sh | 38 ++++++++++++------ images/patches/profile | 20 ++++++++++ images/patches/S50sshd | 50 +++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 13 deletions(-) diff --git a/images/build.sh b/images/build.sh index 66ac829..7d9714e 100755 --- a/images/build.sh +++ b/images/build.sh @@ -93,8 +93,8 @@ export JOBS=`cat /proc/cpuinfo | grep processor | wc -l` export ARCH=arm - ROOTFS_SRC=rootfs - ROOTFS_IMG=rootfs-${BOARD}.ubi + ROOTFS_SRC=rootfs + ROOTFS_IMG=rootfs-${BOARD}.ubi export SRCS="rootfs" } @@ -110,16 +110,16 @@ continue fi - pr_info "start fetch $src source code" - mkdir -p $TARBALL_PATH + pr_info "start fetch $src source code" + mkdir -p $TARBALL_PATH - # Download source code packet - if [ ! -s $TARBALL_PATH/$src.tar.xz ] ; then - wget $BSP_URL/at91/bsp/$BSP_VER/$src.tar.xz -P $TARBALL_PATH - fi + # Download source code packet + if [ ! -s $TARBALL_PATH/$src.tar.xz ] ; then + wget $BSP_URL/at91/bsp/$BSP_VER/$src.tar.xz -P $TARBALL_PATH + fi - # decompress source code packet - do_unpack $TARBALL_PATH/$src.tar.xz $ROOTFS_SRC + # decompress source code packet + do_unpack $TARBALL_PATH/$src.tar.xz $ROOTFS_SRC done } @@ -174,6 +174,16 @@ } +function do_modify() +{ + cd $PRJ_PATH + + pr_info "start modify rootfs ..." + + cp patches/profile $ROOTFS_SRC/etc/profile + cp patches/S50sshd $ROOTFS_SRC/etc/init.d/S50sshd +} + function do_build() { cd $PRJ_PATH @@ -182,7 +192,7 @@ pr_info "start build rootfs image..." build_ubifs - mv $ROOTFS_IMG $PRFX_PATH + mv $ROOTFS_IMG $PRFX_PATH } function do_install() @@ -191,8 +201,8 @@ echo "" pr_info "install all images to '$PRFX_PATH'" - cp $TOP_PATH/bootloader/install/* $PRFX_PATH - cp $TOP_PATH/kernel/install/* $PRFX_PATH + cp $TOP_PATH/bootloader/install/* $PRFX_PATH + cp $TOP_PATH/kernel/install/* $PRFX_PATH ls $PRFX_PATH && echo "" @@ -231,6 +241,8 @@ do_fetch +do_modify + do_build do_install diff --git a/images/patches/S50sshd b/images/patches/S50sshd new file mode 100755 index 0000000..f7223b1 --- /dev/null +++ b/images/patches/S50sshd @@ -0,0 +1,50 @@ +#!/bin/sh +# +# sshd Starts sshd. +# + +# Make sure the ssh-keygen progam exists +[ -f /usr/bin/ssh-keygen ] || exit 0 + +umask 077 + +start() { + # Create any missing keys + /usr/bin/ssh-keygen -A + + # This folder must own by root + chown root.root /var/empty/ + + printf "Starting sshd: " + /usr/sbin/sshd + touch /var/lock/sshd + echo "OK" +} +stop() { + printf "Stopping sshd: " + killall sshd + rm -f /var/lock/sshd + echo "OK" +} +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? + diff --git a/images/patches/profile b/images/patches/profile new file mode 100644 index 0000000..95a284b --- /dev/null +++ b/images/patches/profile @@ -0,0 +1,20 @@ +export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/apps/bin:/apps/tools" + +if [ "$PS1" ]; then + if [ "`id -u`" -eq 0 ]; then + export PS1='[\u@\h \w]# ' + else + export PS1='[\u@\h \w]$ ' + fi +fi + +export PAGER='/bin/more' +export EDITOR='/bin/vi' + +# Source configuration files from /etc/profile.d +for i in /etc/profile.d/*.sh ; do + if [ -r "$i" ]; then + . $i + fi +done +unset i -- Gitblit v1.9.1