File: sftp-symlink.sh

package info (click to toggle)
slic3r 1.3.0%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,536 kB
  • sloc: cpp: 63,126; perl: 21,511; ansic: 6,312; sh: 591; xml: 201; makefile: 37; python: 11
file content (40 lines) | stat: -rwxr-xr-x 993 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Prerequisites
# Environment Variables:
#   UPLOAD_USER - user to upload to sftp server
# KEY is assumed to be path to a ssh key for UPLOAD_USER

DIR=$1
shift
KEY=$1
shift
EXT=$1
shift
FILES=$*

source $(dirname $0)/../common/util.sh
set_pr_id
set_branch
if [ ! -z ${PR_ID+x} ] || [ $current_branch != "master" ]; then
    DIR=${DIR}/branches
fi

if [ -s $KEY ]; then
    for i in $FILES; do 
         filepath=$(readlink -f "$i")
         filepath=$(basename $filepath)
         tmpfile=$(mktemp)

         echo "rm Slic3r-${current_branch}-latest.${EXT}" | sftp -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/"
         echo "symlink $filepath Slic3r-${current_branch}-latest.${EXT} " > $tmpfile 
         sftp -b $tmpfile -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/"
         result=$?
         if [ $? -eq 1 ]; then 
             echo "Error with SFTP symlink"
             exit $result; 
         fi
    done
else
    echo "$KEY is not available, not symlinking." 
fi
exit $result