-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathonce.sh
More file actions
78 lines (56 loc) · 1.51 KB
/
once.sh
File metadata and controls
78 lines (56 loc) · 1.51 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
HOME="/home/pi"
SERVICE="pinkcoin.service"
createPinkconf() {
DAYS=120
DIR="$HOME/.pink2"
FILE="$DIR/pinkconf.txt"
# Generate random 64 character alphanumeric string (upper and lower case)
RPCPASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1)
# Generate random 32 character alpha string (lowercase only)
RPCUSERNAME=$(cat /dev/urandom | tr -dc 'a-z' | fold -w 32 | head -n 1)
# Create initial Pinkcoin Wallet directory
mkdir -p "$DIR"
# Create Pinkcoin Wallet configuration
# Note: File should read as an INI (i.e. PHP)
cat > "$FILE" << EOL
daemon=1
listen=1
rpcallowip="127.0.0.1"
rpcpassword="$RPCPASSWORD"
rpcport=31415
rpcssl=1
rpcsslciphers="TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH"
rpcuser="$RPCUSERNAME"
server=1
staking=1
txindex=1
EOL
# Correct file permissions
chmod 644 "$FILE"
# Generate (sef-signed) SSL Certificate
"$HOME/scripts/wallet_ssl.sh"
}
createSSHCredentials() {
DIR="$HOME/.ssh"
FILE="$DIR/id_rsa"
# Clear any existing setup
rm -fR "$DIR"
# (Re-)Create directory
mkdir -p "$DIR"
chmod 700 "$DIR"
# Generate new SSH Public/Private pair
# TODO Provide access via PinkPiUi
ssh-keygen -b 4096 -t rsa -f "$FILE" -N ""
# Allow this key access
cat "$FILE.pub" >> "$DIR/authorized_keys"
# Remove default password
sudo passwd -d pi
}
# Generate SSH Key (overwrite)
createSSHCredentials
# Generate RPC Credentials (i.e. pinkconf.txt)
createPinkconf
# Self-destruct
sudo sed -i "/once.sh/d" "$HOME/crontab/pinkpi"
sudo rm "$0"