Skip to content

Instantly share code, notes, and snippets.

@luandro
Created July 29, 2025 18:45
Show Gist options
  • Save luandro/de0ff7990ba8535f566e4c3e381dc4d3 to your computer and use it in GitHub Desktop.
Save luandro/de0ff7990ba8535f566e4c3e381dc4d3 to your computer and use it in GitHub Desktop.
updatepkg.sh
#!/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.
# It copy to an ip a specific package on a libremesh node.
# Run it from lime packages folder
# Example:
# ./update_packs.sh 10.13.0.1 ubus-lime-metrics
# 1. Copy a ssh key without password into the node
# 2. Copy specific package or all the packages into the destination ip
sshargs=('-O' '-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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment