forked from tdulcet/Distributed-Computing-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
folding.sh
70 lines (65 loc) · 2.61 KB
/
folding.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Teal Dulcet
# wget https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/folding.sh -qO - | bash -s --
# ./folding.sh [Username] [Team number] [Passkey] [Power]
# ./folding.sh "$USER" 0 "" medium
# ./folding.sh anonymous
# sudo dpkg -P fahclient
# sudo dpkg -P fahcontrol
# sudo dpkg -P fahviewer
DIR="folding"
if [[ $# -gt 4 ]]; then
echo "Usage: $0 [Username] [Team number] [Passkey] [Power]" >&2
exit 1
fi
USERID=${1:-$USER}
TEAM=${2:-0}
PASSKEY=${3:-}
POWER=${4:-medium}
RE='^[0-9]+$'
if ! [[ $TEAM =~ $RE ]]; then
echo "Usage: [Team number] must be a number" >&2
exit 1
fi
RE='^[[:xdigit:]]{32}$'
if ! [[ -z "$PASSKEY" || $PASSKEY =~ $RE ]]; then
echo "Usage: [Passkey] must be blank or a 32 digit hexadecimal number" >&2
exit 1
fi
RE='^(light|medium|full)$'
if ! [[ $POWER =~ $RE ]]; then
echo "Usage: [Power] is not valid" >&2
exit 1
fi
echo -e "Username:\t$USERID"
echo -e "Team number:\t$TEAM"
echo -e "Passkey:\t$PASSKEY"
echo -e "Power:\t\t$POWER\n"
wget https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/idletime.sh -qO - | bash -s
if [[ -d "$DIR" ]] && command -v FAHClient >/dev/null; then
echo "Error: Folding@home is already downloaded and installed" >&2
exit 1
fi
if ! mkdir "$DIR"; then
echo "Error: Failed to create directory $DIR" >&2
exit 1
fi
cd "$DIR"
echo -e "Downloading Folding@home\n"
wget https://download.foldingathome.org/releases/public/release/fahclient/debian-stable-64bit/v7.5/fahclient_7.5.1_amd64.deb
wget https://download.foldingathome.org/releases/public/release/fahcontrol/debian-stable-64bit/v7.5/fahcontrol_7.5.1-1_all.deb
wget https://download.foldingathome.org/releases/public/release/fahviewer/debian-stable-64bit/v7.5/fahviewer_7.5.1_amd64.deb
echo -e "\nInstalling Folding@home"
echo -e "Please enter your password when prompted.\n"
# Adapted from: https://www.linuxquestions.org/questions/blog/bittner-195120/howto-automate-interactive-debian-package-installations-debconf-preseeding-2879/
# dpkg-deb -e fahclient_7.5.1_amd64.deb control_files/
# grep -e '^Template:' -e '^Type:' -e '^Default:' control_files/templates | xargs | sed -e 's/\s*Template: /\nFAHClient\t/g' -e 's/\s*Type: */\t/g' -e 's/\s*Default: */\t/g' > FAHClient.conf
sudo debconf-set-selections <<< "FAHClient fahclient/user string $USERID
FAHClient fahclient/team string $TEAM
FAHClient fahclient/passkey string $PASSKEY
FAHClient fahclient/power select $POWER
FAHClient fahclient/autostart boolean true"
sudo dpkg -i --force-depends fahclient_7.5.1_amd64.deb
sudo dpkg -i --force-depends fahcontrol_7.5.1-1_all.deb
sudo dpkg -i --force-depends fahviewer_7.5.1_amd64.deb
# sudo apt-get install -f