Re: [lime] Ways to update librerouter packages

Borrar esta mensaxe

Responder a esta mensaxe
Autor: Selan Kon
Data:  
Para: libremesh
Asunto: Re: [lime] Ways to update librerouter packages


Selan Kon via LibreMesh:
>
> Selan Kon via LibreMesh:
>> Hi all!
>>
>> I want to try a modified version of lime packages on a librerouter and
>> I'm looking for a good way to send the packages from my computer to
>> there.
>>
>> I found this bash piece on the qemu script that could be a starting
>> point:
>>
>> ```bash
>> # if a libremesh workdir is specified then we copy the files from the
>> workdir
>> # into the rootfs
>> if [ "$_arg_libremesh_workdir" ]; then
>>      # Copying the new lime overlay here
>>      for package in "${_arg_libremesh_workdir}"/packages/*/files/*; do
>>          cp -r "${package}" $temp_dir
>>      done
>> fi
>> ```


Hey

I updated this script a little bit with some improvements. Should I add
it to tools folder on lime-packages? Create a git gist?

Is really simple and could break, but is enough to update all lime
packages or a specific one, creating also an empty temporal ssh key and
adding it to dropbear.

#!/bin/bash
# THIS SCRIPT IS FOR DEVELOPMENT USSAGE ONLY
# Do not use it on production
# It creates a temporal unprotected ssh key and add it as unique key on the
# /etc/dropbear/authorized_keys on destination ip, which is not safe.

sshargs=('-o' "UserKnownHostsFile=/dev/null" '-o'
"StrictHostKeyChecking=no" )
keyfile="/tmp/tmp_key"


if [ $# -eq 0 ]; then
     echo "Usage:"
     echo "Copy recursivelly all lime packages"
     echo "  ./update_packages.sh <DEST_IP>"
     echo "Copy specific package"
     echo "  ./update_packages.sh <DEST_IP> <LIME_PACKAGE>"
     exit 1
fi


# Create tmp rsa key
if [ ! -f "$keyfile" ]; then
     echo "Creating empty password keyfile"
     ssh-keygen -t rsa -b 4096 -f $keyfile -q -N ""
     echo "Copying public key file to destination"
     <$keyfile.pub ssh "${sshargs[@]}" -i $keyfile root@$1 "cat > 
/etc/dropbear/authorized_keys"
     # ssh-copy-id  not work because auth keys are stored on /etc/dropbear
     # ssh-copy-id -o "UserKnownHostsFile=/dev/null" -o 
"StrictHostKeyChecking=no" -i $keyfile root@$1
fi


# Specific package to copy
if [ ! -z "$2" ]; then
     pacfolder="packages/$2"
     if [ ! -d $pacfolder ]; then
         echo "Package $2 doesn't exist"
         exit 1
     fi
     echo "Copying specific package $2"
     scp "${sshargs[@]}" -i $keyfile -r packages/$2/files/* root@$1:/
     #&& sshf root@$1 '/etc/init.d/rpcd stop && /etc/init.d/rpcd start'
else
     # Copying the new lime overlay here
     for package in ./packages/*/files/*; do
         scp "${sshargs[@]}" -i $keyfile -r "${package}" root@$1:/
     done
fi




>>
>> It only needs to be modified using scp and something else. How do you
>> do this? Any recommendations?
>
> Something like that 👍
>
>
> for package in ./packages/*/files/*; do
>     scp -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no"
> -r "${package}" root@10.13.0.1:/
> done