From fffdf9f5a7918070577ff6a96f083e957c2cf377 Mon Sep 17 00:00:00 2001 From: dufourj Date: Mon, 16 Jan 2006 14:48:18 +0000 Subject: PC104 : - ajout du script d'update ; - corrections mineurs dans le script de création d'initrd. --- i/pc104/initrd/conf/linuxrc | 16 +++---- i/pc104/initrd/create.sh | 6 ++- i/pc104/initrd/update.sh | 107 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 9 deletions(-) create mode 100755 i/pc104/initrd/update.sh (limited to 'i/pc104/initrd') diff --git a/i/pc104/initrd/conf/linuxrc b/i/pc104/initrd/conf/linuxrc index e7973eb..7b1e789 100755 --- a/i/pc104/initrd/conf/linuxrc +++ b/i/pc104/initrd/conf/linuxrc @@ -1,20 +1,20 @@ -#!/bin/ash +#!/bin/sh # Executed in autonomous mode for the matchs # Mount tmp fs mount /proc # Try to to tell people we have booted ! -for i in $(seq 0 5) -do - echo -ne "\033" -done +#for i in $(seq 0 5) +#do + echo -ne "\007" +#done # TODO Export variables (LD...) # Launch the program -# ./robot/start.sh - +# . /robot/start.sh +# while true do - /bin/ash + /bin/sh done diff --git a/i/pc104/initrd/create.sh b/i/pc104/initrd/create.sh index b991c83..b0d66ab 100755 --- a/i/pc104/initrd/create.sh +++ b/i/pc104/initrd/create.sh @@ -54,7 +54,9 @@ create_empty_struct () # Create all the devices files we need create_dev # Fstab - install -m 755 $INITRD_CONFIG_DIR/fstab $INITRD_TEMPDIR/etc/fstab + install -m 644 $INITRD_CONFIG_DIR/fstab $INITRD_TEMPDIR/etc/fstab + # Inittab + #install -m 644 $INITRD_CONFIG_DIR/inittab $INITRD_TEMPDIR/etc/inittab # Copy the linuxrc script install -m 755 $INITRD_CONFIG_DIR/linuxrc $INITRD_TEMPDIR/linuxrc } @@ -70,6 +72,8 @@ create_dev () $makedev -v std # Create the console for logging ? Useful ? XXX $makedev -v consoleonly + #tty1 tty2 tty3 tty4 tty5 + #$makedev -v ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 ttyS5 ttyS6 # XXX Complete... # Back to the originated directory cd $cur_dir diff --git a/i/pc104/initrd/update.sh b/i/pc104/initrd/update.sh new file mode 100755 index 0000000..9cb9059 --- /dev/null +++ b/i/pc104/initrd/update.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# Script for updating the marvin program in the initrd. + +# Variables - Default values +# Local directory name containing the representation for the initrd +ROBOT_LOCAL_DIR="./robot" +# Remote directory in the initrd +ROBOT_REMOTE_DIR="/robot" +# Name of the script to launch the robot program +ROBOT_START_SCRIPT="start.sh" +# Build directory +ROBOT_BUILD_DIR="." +# Config directory +ROBOT_CONF_DIR="$ROBOT_BUILD_DIR/../runtime" +# Max size of the config directory +ROBOT_CONF_MAX_SIZE="3000" + +check_rsync () +{ + if [[ "x$(whereis rsync | cut -d ':' -f 2)" == "x" ]] + then + echo "Please install rsync" + exit 1 + fi +} +# Check the structure (directory robot and startup script) +check_create_structure () +{ + # Check the local directory exist + if [[ ! -d $ROBOT_LOCAL_DIR ]] + then + mkdir $ROBOT_LOCAL_DIR + fi + # Check we have a start script + if [[ ! -f $ROBOT_LOCAL_DIR/$ROBOT_START_SCRIPT ]] + then + # Create a default one + echo -e \ + "# Startup script launched when the PC104 boot.\n\ +# It will be sourced by other script.\n\ +# Example : \n\ +# ./test_ai -z" > $ROBOT_LOCAL_DIR/$ROBOT_START_SCRIPT + # Need to tune it by the user + echo "Please tune your $ROBOT_LOCAL_DIR/$ROBOT_START_SCRIPT." + # XXX vim it ? + exit 2 + fi +} + +# Check that there is a line in the startup script for launchin a program and +# a binary existing +check_install_binary () +{ + if [[ $(grep -cv "^#" $ROBOT_LOCAL_DIR/$ROBOT_START_SCRIPT) -eq 0 ]] + then + echo "No command found in your $ROBOT_LOCAL_DIR/$ROBOT_START_SCRIPT." + exit 3 + fi + for line in "$(grep -v "^#" $ROBOT_LOCAL_DIR/$ROBOT_START_SCRIPT)" + do + bin="$(echo "$line" | cut -d ' ' -f 1)" + if [[ ! -x $ROBOT_BUILD_DIR/$bin ]] + then + echo "Binary not found : $bin." + exit 4 + else + # Copy the binary to the local dir + install -m 777 $ROBOT_BUILD_DIR/$bin $ROBOT_LOCAL_DIR/ + # Remove useless symbol + strip $ROBOT_LOCAL_DIR/$bin + fi + done +} + +# Install the configuration +check_install_config () +{ + # First we check the size + if [[ $(du -bs $ROBOT_CONF_DIR | cut -f 1) -gt $ROBOT_CONF_MAX_SIZE ]] + then + echo "Config directory ($ROBOT_CONF_DIR) is too big." + exit 5 + fi + # There is no way to know the files needed, so we rsync everything + rsync -aq $ROBOT_CONF_DIR/ $ROBOT_LOCAL_DIR/rc +} + +# TODO Send it to the initrd +# Guiding steps : +# 1. Try netcat on the robot +# 1.a If it responding, we are in autonomous mode, wait that the PC104 mount +# the real system for ssh +# 2. Try ssh +# 2.a Not responding, wrong robot/dns ? Too quick from 1 ? +# 3. Backuper/rotater l'initrd +# 4. Décompréssé l'initrd +# 5. Le monter +# 6. rsyncer +# 7. Démonter +# 8. Re-compresser + +# TODO Parameter + +check_rsync +check_create_structure +check_install_binary +check_install_config -- cgit v1.2.3