-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_payload.sh
executable file
·46 lines (38 loc) · 1021 Bytes
/
add_payload.sh
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
#!/bin/bash
# From: http://www.linuxjournal.com/content/add-binary-payload-your-shell-scripts
TEMPLATE_FILE=setup_proteomics_wine_env.sh.template
INSTALL_FILE=setup_proteomics_wine_env.sh
# Check for payload format option (default is uuencode).
uuencode=1
if [[ "$1" == '--binary' ]]; then
binary=1
uuencode=0
shift
fi
if [[ "$1" == '--uuencode' ]]; then
binary=0
uuencode=1
shift
fi
if [[ ! "$1" ]]; then
echo "Usage: $0 [--binary | --uuencode] PAYLOAD_FILE"
exit 1
fi
if [[ $binary -ne 0 ]]; then
# Append binary data.
sed \
-e 's/uuencode=./uuencode=0/' \
-e 's/binary=./binary=1/' \
$TEMPLATE_FILE >$INSTALL_FILE
echo "PAYLOAD:" >> $INSTALL_FILE
cat $1 >>$INSTALL_FILE
fi
if [[ $uuencode -ne 0 ]]; then
# Append uuencoded data.
sed \
-e 's/uuencode=./uuencode=1/' \
-e 's/binary=./binary=0/' \
$TEMPLATE_FILE >$INSTALL_FILE
echo "PAYLOAD:" >> $INSTALL_FILE
cat $1 | uuencode - >>$INSTALL_FILE
fi