blob: 9b28eed12dd4d91ebfd2655c1031241f4f9449d3 (
plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<!doctype html>
<html lang="EN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style.css">
<title>Upload modified blog files with scp</title>
</head>
<body>
<header>
<h1>Bloggings</h1>
<a href="/index.php">Back</a>
</header>
<main>
<article>
<h2>Upload modified blog files with scp</h2>
<h3>2025-03-29</h3>
<h4>A simple bash script to update this blog using scp</h4>
<h3>Note</h3>
<p>I have my web server aliased in ~/.ssh/config as "web" <br>so the remote folder is web:/folder</p>
<code>#!/bin/sh
# blogsend : scp blog files to web server
# usage : <b>blogsend</b> <i>hours</i> (if not set default is 1 hour)
# example : <b>blogsend 72</b> sends files modified over the past 3 days
# folders
rf= <i>#add your remote ssh folder here</i>
mf= <i>#add your local folder here</i>
cd $mf
# test if option is sent
if [[ -z "$1" ]]; then
HOURS=1;
else
# test if option is a number
if [[ "$1" =~ ^[0-9]+$ ]]; then
HOURS=$1;
else
HOURS=1;
fi
fi
MINUTES=$(($HOURS*60))
echo "Sending files modified in the past $HOURS hour(s)..."
files=$(find * -path .tmp -prune -o -mmin -$MINUTES -type f)
for file in $files
do
echo -ne "-> ";
scp -r "$file" "$rf/$file";
done
echo "Done."
exit 0
</code>
</article>
</main>
<footer>
<p> </p><p>§</p></footer>
</body></html>
|