slitaz-forge view usbkey/helper.sh @ rev 717

mirror/floppies: add mkmdsum.sh
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Aug 20 11:39:45 2021 +0000 (2021-08-20)
parents 134d8a603e7f
children
line source
1 #!/bin/sh
3 if [ "$1" = "--stats" ]; then
4 dir=$(dirname $0)/$2
5 if [ -n "$3" ]; then
6 sed 's/.*"\([0-9]* Gb\)".*/\1/' $dir/?/* | sort | awk '{
7 if ($0 != last && last != "") {
8 print last " : " n
9 n = 0
10 }
11 last = $0
12 n++
13 }
14 END {
15 print last " : " n
16 }'
17 else
18 sed '/"count";s:1:/!d;s/.*"count";s:1:"\([0-9]*\)";.*/\1/' $dir/?/* | \
19 awk 'BEGIN { n=0 }{ n+=$0 } END { print n }'
20 fi
21 exit
22 fi
24 DOMAIN="slitaz.org"
25 SERVER="127.0.0.1"
26 SUBJECT="usbkey.slitaz.org confirmation"
27 BCC="pascal.bellard@slitaz.org"
29 SENDTO="$1"
30 SURNAME="$2"
31 KEYSIZE="$3"
32 HASH="$4"
34 body()
35 {
36 cat <<EOT
37 From: usbkey-preorder@$DOMAIN
38 Reply-To: no-reply@$DOMAIN
39 To: $SENDTO
40 Date: $(LC_ALL=C date '+%a, %d %b %Y %H:%M:%S %z')
41 Subject: $SUBJECT
43 Hello $SURNAME,
45 A $KEYSIZE SliTaz USB key has been reserved for you.
46 Would you mind confirming your pre-order with the following link
47 http://usbkey.slitaz.org/?confirm=$HASH
49 Or cancelling the registration with the following link
50 http://usbkey.slitaz.org/?cancel=$HASH
52 Thanks,
53 The SliTaz team.
54 EOT
55 }
57 send()
58 {
59 if [ -x /usr/sbin/sendmail ]; then
60 body | /usr/sbin/sendmail $SENDTO
61 else
62 /usr/bin/nc $SERVER 25 <<EOT
63 HELO $SERVER
64 MAIL FROM:<usbkey-preorder@$DOMAIN>
65 RCPT TO:$SENDTO
66 DATA
67 $(body)
69 .
70 QUIT
71 EOT
72 fi
73 }
75 send
76 SUBJECT="[bcc of $SENDTO] $SUBJECT"
77 for SENDTO in $BCC ; do
78 send
79 done