summaryrefslogtreecommitdiff
path: root/i/pc104/initrd
diff options
context:
space:
mode:
authordufourj2006-02-07 16:48:34 +0000
committerdufourj2006-02-07 16:48:34 +0000
commitac2c13bf199df9673b3ced0ebd32e6fdff634a03 (patch)
tree1f19138fd067d4e6ae4046a163f1a41c194db1c0 /i/pc104/initrd
parent0a80b89fdb01a15a1c601dc32c461713059834c9 (diff)
PC104 - initrd :
* update : - nettoyage pour éviter les fichiers inutiles ; - meilleur gestion de la dépendances des libs ; - diminution du niveau de compression ; - utilisation de /dev/shm pour gagner du temps ; - corrections de bugs diverses. * create : - lien symbolique pour /lib pour pouvoir éxécuter des binaires.
Diffstat (limited to 'i/pc104/initrd')
-rwxr-xr-xi/pc104/initrd/conf/rcS3
-rwxr-xr-xi/pc104/initrd/create.sh4
-rwxr-xr-xi/pc104/initrd/update.sh61
3 files changed, 49 insertions, 19 deletions
diff --git a/i/pc104/initrd/conf/rcS b/i/pc104/initrd/conf/rcS
index 0c1012c..af46880 100755
--- a/i/pc104/initrd/conf/rcS
+++ b/i/pc104/initrd/conf/rcS
@@ -16,7 +16,8 @@ mount /proc
# Launch the program ! Go Go Go !
# For the library
-export LD_LIBRARY_PATH="./lib/;/robot/lib/"
+export LD_LIBRARY_PATH="./lib/:/robot/lib/:/lib"
+export PATH="/robot/:$PATH"
# Go to the directory where everything is
cd /robot/
# According to some scripts I have seen, it is quicker because it removes a
diff --git a/i/pc104/initrd/create.sh b/i/pc104/initrd/create.sh
index 342ddf8..3057c97 100755
--- a/i/pc104/initrd/create.sh
+++ b/i/pc104/initrd/create.sh
@@ -63,6 +63,8 @@ create_empty_struct ()
install -m 755 $INITRD_CONFIG_DIR/update_initrd.sh $INITRD_TEMPDIR/etc/robot/update_initrd.sh
# Udhcpc script
install -m 755 $INITRD_CONFIG_DIR/udhcpc.script $INITRD_TEMPDIR/etc/udhcpc.script
+ # Library
+ ln -s /robot/lib $INITRD_TEMPDIR/lib
}
create_dev ()
@@ -147,7 +149,7 @@ umount_initrd ()
# Need a compression ?
if (( $INITRD_COMPRESS == 0 ))
then
- gzip -f -9 $INITRD_OUTPUT
+ gzip -f -4 $INITRD_OUTPUT
fi
}
diff --git a/i/pc104/initrd/update.sh b/i/pc104/initrd/update.sh
index 1fe8c58..d04a125 100755
--- a/i/pc104/initrd/update.sh
+++ b/i/pc104/initrd/update.sh
@@ -20,19 +20,21 @@ ROBOT_MAX_SIZE="4000000"
# Hostname of the robot
ROBOT_HOST="nenuphar"
# In autonomous mode, wait time for bringing up the ssh deamon
-ROBOT_WAIT_TIME="3s"
+ROBOT_WAIT_TIME="2.5s"
# Compression
ROBOT_NOCOMPRESS=0
# Quiet ?
ROBOT_QUIET=0
# SSH options
-ROBOT_SSH_OPTS="-o \"ConnectionAttempts 4\" -o \"ConnectTimeout 1\""
+ROBOT_SSH_OPTS="-o ConnectTimeout 1"
+# Force autonomous mode
+ROBOT_FORCE_AUTONOMOUS=0
if [ $# -gt 6 ]
then
usage
fi
-while getopts "b:s:r:zqh" option
+while getopts "b:s:r:zaqh" option
do
case $option in
b) ROBOT_BUILD_DIR="$OPTARG";;
@@ -40,6 +42,7 @@ do
s) ROBOT_CONF_MAX_SIZE="$OPTARG";;
r) ROBOT_HOST="$OPTARG";;
z) ROBOT_NOCOMPRESS=1;;
+ a) ROBOT_FORCE_AUTONOMOUS=1;;
q) ROBOT_QUIET=1;;
h) help_initrd;;
\?) help_initrd;;
@@ -86,6 +89,7 @@ usage ()
echo " -s <size> : size max of binaries and config (in bytes)"
echo " -r <host> : robot host"
echo " -z : disable compression"
+ echo " -z : force automous mode (for second update)"
echo " -q : be quiet (expect for errors)"
echo " -h : this message"
exit
@@ -114,7 +118,8 @@ check_create_structure ()
# Create a default one
cat <<EOF > $ROBOT_LOCAL_DIR/$ROBOT_START_SCRIPT
# Startup script launched when the PC104 boot.
-# It will be sourced by other script.
+# It will be executde by other script.
+# IMPORTANT : the commande must begin with a "./" !
# Example :
# ./test_ai -z
EOF
@@ -123,6 +128,15 @@ EOF
log_error "Please tune your $ROBOT_LOCAL_DIR/$ROBOT_START_SCRIPT"
# XXX vim it ?
exit 2
+ else
+ # A little bit of cleaning
+ for file in $ROBOT_LOCAL_DIR/*
+ do
+ if [[ ! -d $file && $file != "$ROBOT_LOCAL_DIR/$ROBOT_START_SCRIPT" ]]
+ then
+ rm -f $file
+ fi
+ done
fi
log "Ok" 3
}
@@ -150,7 +164,12 @@ check_install_binary ()
# Remove useless symbol
strip -p $ROBOT_LOCAL_DIR/$bin
# Copy needed libraries
- for lib in "$(ldd $ROBOT_BUILD_DIR/$bin | cut -d ' ' -f 3)"
+ for lib in $(ldd $ROBOT_BUILD_DIR/$bin | cut -d ' ' -f 3)
+ do
+ cp -p $lib $ROBOT_LOCAL_DIR/lib
+ done
+ # For the one that begins with a /
+ for lib in $(ldd $ROBOT_BUILD_DIR/$bin | grep -E "^[[:space:]]*/" | cut -f 2 |cut -f 1 -d ' ')
do
cp -p $lib $ROBOT_LOCAL_DIR/lib
done
@@ -217,6 +236,9 @@ upload_data ()
ROBOT_AUTONOMOUS=0
# Are we in automous mode ?
log "Autonomous mode" 2
+ if (( $ROBOT_FORCE_AUTONOMOUS == 1 )); then
+ ROBOT_AUTONOMOUS=1
+ fi
nc -w 1 $ROBOT_HOST 1234 > /dev/null 2>&1
if [[ $? -eq 0 ]]
then
@@ -231,44 +253,49 @@ upload_data ()
log "Mouting the initrd" 2
if (( $ROBOT_AUTONOMOUS == 1 )); then
- ssh $ROBOT_SSH_OPTS root@$ROBOT_HOST "\
- mount -oremount,rw / && \
- gunzip -f -c /initrd/last > /tmp/initrd_cur && \
- mount -o loop /tmp/initrd_cur /mnt/initrd"
+ ssh "$ROBOT_SSH_OPTS" root@$ROBOT_HOST "\
+ gunzip -f -c /initrd/last > /dev/shm/initrd_cur && \
+ mount -o loop /dev/shm/initrd_cur /mnt/initrd"
else
- false
# TODO not implemented yet
+ log "Not implemented..." 3
fi
log "Ok" 3
# Rsync data
- log "Rsyncing data"
+ log "Rsyncing data" 2
rsync -au $ROBOT_LOCAL_DIR/ root@$ROBOT_HOST:/mnt/initrd/$ROBOT_REMOTE_DIR/
log "Ok" 3
# Dmonter et recompresser l'initrd voir rotater tout
# TODO Backup, rotation, et less cp !
- log "Umounting the initrd and move it" 2
if (( $ROBOT_AUTONOMOUS == 1 )); then
if (( $ROBOT_NOCOMPRESS == 1 )); then
- ssh $ROBOT_SSH_OPTS root@$ROBOT_HOST "\
+ log "Umounting the initrd and move it" 2
+ ssh "$ROBOT_SSH_OPTS" root@$ROBOT_HOST "\
umount /mnt/initrd && \
- mv /tmp/initrd_cur /initrd/initrd1.gz && \
+ mount -oremount,rw / && \
+ mv /dev/shm/initrd_cur /initrd/initrd1.gz && \
+ rm -f /dev/shm/initrd_cur && \
sync && \
mount -oremount,ro / && \
kill -SIGTERM 1"
else
+ log "Umounting the initrd and compress it" 2
# XXX Remove /tmp/initrd_cur after compression ?
- ssh $ROBOT_SSH_OPTS root@$ROBOT_HOST "\
+ ssh "$ROBOT_SSH_OPTS" root@$ROBOT_HOST "\
umount /mnt/initrd && \
- gzip -f -1 -c /tmp/initrd_cur > /initrd/initrd1.gz && \
+ mount -oremount,rw / && \
+ gzip -f -4 -c /dev/shm/initrd_cur > /initrd/initrd1.gz && \
+ rm -f /dev/shm/initrd_cur && \
sync && \
mount -oremount,ro / && \
kill -SIGTERM 1"
fi
else
+ log "Umounting the initrd and move it" 2
# TODO
- false
+ log "Not implemented..." 3
fi
log "Ok... Rebooting" 3
}