#16 Refactor vyos.sh to accept alternative ssh and scp command configurations, adapt vyos-deploy to pass new SSH_CMD and SCP_CMD
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 12s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 12s
This commit is contained in:
parent
e88b422864
commit
d329ee1e1d
@ -28,9 +28,8 @@ jobs:
|
|||||||
ssh-keyscan -t ed25519 192.168.1.1 >> ~/.ssh/known_hosts
|
ssh-keyscan -t ed25519 192.168.1.1 >> ~/.ssh/known_hosts
|
||||||
- name: Connect to VyOS
|
- name: Connect to VyOS
|
||||||
run: |
|
run: |
|
||||||
ssh -i /tmp/key -p 22 vyos@192.168.1.1 'whoami'
|
ssh -i /tmp/key vyos@192.168.1.1 'whoami'
|
||||||
alias ssh='ssh -i /tmp/key -p 22'
|
SSH_CMD="ssh -i /tmp/key" SCP_CMD="scp -i /tmp/key -q" ./vyos.sh op show system image
|
||||||
./vyos.sh op show system image
|
|
||||||
|
|
||||||
# - name: SSH into host
|
# - name: SSH into host
|
||||||
# uses: appleboy/ssh-action@v1.1.0
|
# uses: appleboy/ssh-action@v1.1.0
|
||||||
|
@ -2,61 +2,66 @@
|
|||||||
|
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
# Change this to the user, host, (and optionally port) of your VyOS target.
|
SSH_CMD=${SSH_CMD:-"ssh"}
|
||||||
VYOS_TARGET="vyos@192.168.1.1"
|
SCP_CMD=${SCP_CMD:-"scp -q"}
|
||||||
|
VYOS_TARGET=${VYOS_TARGET:-"vyos@192.168.1.1"}
|
||||||
|
|
||||||
|
echo "SSH_CMD: $SSH_CMD"
|
||||||
|
echo "SCP_CMD: $SCP_CMD"
|
||||||
|
echo "VYOS_TARGET: $VYOS_TARGET"
|
||||||
|
|
||||||
# Returns saved config file
|
# Returns saved config file
|
||||||
function get_config_saved () {
|
function get_config_saved () {
|
||||||
ssh $VYOS_TARGET 'cat /config/config.boot'
|
$SSH_CMD $VYOS_TARGET 'cat /config/config.boot'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns active config file
|
# Returns active config file
|
||||||
function get_config_active () {
|
function get_config_active () {
|
||||||
scp -q ./get_config.sh $VYOS_TARGET:/home/vyos/get_config.sh
|
$SCP_CMD ./get_config.sh $VYOS_TARGET:/home/vyos/get_config.sh
|
||||||
ssh $VYOS_TARGET 'chmod +x /home/vyos/get_config.sh; /home/vyos/get_config.sh; rm /home/vyos/get_config.sh'
|
$SSH_CMD $VYOS_TARGET 'chmod +x /home/vyos/get_config.sh; /home/vyos/get_config.sh; rm /home/vyos/get_config.sh'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Push local ./config.boot to remote /home/vyos/config.boot
|
# Push local ./config.boot to remote /home/vyos/config.boot
|
||||||
function post_config () {
|
function post_config () {
|
||||||
scp -q ./config.boot $VYOS_TARGET:/home/vyos/config.boot
|
$SCP_CMD ./config.boot $VYOS_TARGET:/home/vyos/config.boot
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_config () {
|
function load_config () {
|
||||||
scp -q ./load_config.sh $VYOS_TARGET:/home/vyos/load_config.sh
|
$SCP_CMD ./load_config.sh $VYOS_TARGET:/home/vyos/load_config.sh
|
||||||
ssh $VYOS_TARGET 'chmod +x /home/vyos/load_config.sh; /home/vyos/load_config.sh; rm /home/vyos/load_config.sh'
|
$SSH_CMD $VYOS_TARGET 'chmod +x /home/vyos/load_config.sh; /home/vyos/load_config.sh; rm /home/vyos/load_config.sh'
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_config () {
|
function save_config () {
|
||||||
scp -q ./save_config.sh $VYOS_TARGET:/home/vyos/save_config.sh
|
$SCP_CMD ./save_config.sh $VYOS_TARGET:/home/vyos/save_config.sh
|
||||||
ssh $VYOS_TARGET 'chmod +x /home/vyos/save_config.sh; /home/vyos/save_config.sh; rm /home/vyos/save_config.sh'
|
$SSH_CMD $VYOS_TARGET 'chmod +x /home/vyos/save_config.sh; /home/vyos/save_config.sh; rm /home/vyos/save_config.sh'
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_dhcp_leases () {
|
function get_dhcp_leases () {
|
||||||
scp -q ./op.sh $VYOS_TARGET:/home/vyos/op.sh
|
$SCP_CMD ./op.sh $VYOS_TARGET:/home/vyos/op.sh
|
||||||
ssh $VYOS_TARGET 'chmod +x /home/vyos/op.sh; /home/vyos/op.sh "show dhcp server leases"; rm /home/vyos/op.sh'
|
$SSH_CMD $VYOS_TARGET 'chmod +x /home/vyos/op.sh; /home/vyos/op.sh "show dhcp server leases"; rm /home/vyos/op.sh'
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_public_ip () {
|
function update_public_ip () {
|
||||||
scp -q ./update_public_ip.sh $VYOS_TARGET:/home/vyos/update_public_ip.sh
|
$SCP_CMD ./update_public_ip.sh $VYOS_TARGET:/home/vyos/update_public_ip.sh
|
||||||
ssh $VYOS_TARGET 'chmod +x /home/vyos/update_public_ip.sh; /home/vyos/update_public_ip.sh; rm /home/vyos/update_public_ip.sh'
|
$SSH_CMD $VYOS_TARGET 'chmod +x /home/vyos/update_public_ip.sh; /home/vyos/update_public_ip.sh; rm /home/vyos/update_public_ip.sh'
|
||||||
}
|
}
|
||||||
|
|
||||||
function cfddns () {
|
function cfddns () {
|
||||||
scp -q ./cfddns.sh $VYOS_TARGET:/home/vyos/cfddns.sh
|
$SCP_CMD ./cfddns.sh $VYOS_TARGET:/home/vyos/cfddns.sh
|
||||||
scp -q ./cloudflare.token $VYOS_TARGET:/home/vyos/cloudflare.token
|
$SCP_CMD ./cloudflare.token $VYOS_TARGET:/home/vyos/cloudflare.token
|
||||||
ssh $VYOS_TARGET 'chmod +x /home/vyos/cfddns.sh; /home/vyos/cfddns.sh "jafner.net" "$(cat /home/vyos/cloudflare.token)"; rm /home/vyos/cfddns.sh /home/vyos/cloudflare.token'
|
$SSH_CMD $VYOS_TARGET 'chmod +x /home/vyos/cfddns.sh; /home/vyos/cfddns.sh "jafner.net" "$(cat /home/vyos/cloudflare.token)"; rm /home/vyos/cfddns.sh /home/vyos/cloudflare.token'
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_script () {
|
function run_script () {
|
||||||
SCRIPT="$1"
|
SCRIPT="$1"
|
||||||
scp -q $SCRIPT $VYOS_TARGET:/home/vyos/$SCRIPT
|
$SCP_CMD $SCRIPT $VYOS_TARGET:/home/vyos/$SCRIPT
|
||||||
ssh $VYOS_TARGET "chmod +x /home/vyos/$SCRIPT; /home/vyos/$SCRIPT; rm /home/vyos/$SCRIPT"
|
$SSH_CMD $VYOS_TARGET "chmod +x /home/vyos/$SCRIPT; /home/vyos/$SCRIPT; rm /home/vyos/$SCRIPT"
|
||||||
}
|
}
|
||||||
|
|
||||||
function op () {
|
function op () {
|
||||||
command="$@"
|
command="$@"
|
||||||
scp -q ./op.sh $VYOS_TARGET:/home/vyos/op.sh
|
$SCP_CMD ./op.sh $VYOS_TARGET:/home/vyos/op.sh
|
||||||
ssh $VYOS_TARGET "chmod +x /home/vyos/op.sh; /home/vyos/op.sh $command; rm /home/vyos/op.sh"
|
$SSH_CMD $VYOS_TARGET "chmod +x /home/vyos/op.sh; /home/vyos/op.sh $command; rm /home/vyos/op.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
function pull () {
|
function pull () {
|
||||||
|
Loading…
Reference in New Issue
Block a user