Skip to content

Commit 7df4705

Browse files
mattsblacktdulcet
andauthored
Updated Folding@home script (#26)
Co-authored-by: Teal Dulcet <[email protected]>
1 parent f17c7c8 commit 7df4705

File tree

1 file changed

+40
-20
lines changed

1 file changed

+40
-20
lines changed

folding.sh

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22

33
# Copyright © 2020 Teal Dulcet
44
# wget -qO - https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/folding.sh | bash -s --
5-
# ./folding.sh [Username] [Team number] [Passkey] [Power]
6-
# ./folding.sh "$USER" 0 "" medium
5+
# ./folding.sh [Username] [Team number] [Passkey] [Power] [Account Token]
6+
# ./folding.sh "$USER" 0 "" medium ""
77
# ./folding.sh anonymous
88

99
# sudo dpkg -P fahclient
1010
# sudo dpkg -P fahcontrol
1111
# sudo dpkg -P fahviewer
1212

1313
DIR="folding"
14-
if [[ $# -gt 4 ]]; then
15-
echo "Usage: $0 [Username] [Team number] [Passkey] [Power]" >&2
14+
if [[ $# -gt 5 ]]; then
15+
echo "Usage: $0 [Username] [Team number] [Passkey] [Power] [Account Token]" >&2
1616
exit 1
1717
fi
1818
USERID=${1:-$USER}
1919
TEAM=${2:-0}
2020
PASSKEY=${3:-}
2121
POWER=${4:-medium}
22+
TOKEN=${5:-}
2223
RE='^[0-9]+$'
2324
if ! [[ $TEAM =~ $RE ]]; then
2425
echo "Usage: [Team number] must be a number" >&2
@@ -37,13 +38,18 @@ fi
3738
echo -e "Username:\t$USERID"
3839
echo -e "Team number:\t$TEAM"
3940
echo -e "Passkey:\t$PASSKEY"
40-
echo -e "Power:\t\t$POWER\n"
41+
echo -e "Power:\t\t$POWER"
42+
if [[ -z $TOKEN ]]; then
43+
echo -e "\nAccount Token is not set, using default settings\n"
44+
else
45+
echo -e "Account Token:\t\t$TOKEN\n"
46+
fi
4147
if [[ -e idletime.sh ]]; then
4248
bash -- idletime.sh
4349
else
4450
wget -qO - https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/idletime.sh | bash -s
4551
fi
46-
if [[ -d $DIR ]] && command -v FAHClient >/dev/null; then
52+
if [[ -d $DIR ]] && command -v fah-client >/dev/null; then
4753
echo "Error: Folding@home is already downloaded and installed" >&2
4854
exit 1
4955
fi
@@ -53,22 +59,36 @@ if ! mkdir "$DIR"; then
5359
fi
5460
cd "$DIR"
5561
echo -e "Downloading Folding@home\n"
56-
wget https://download.foldingathome.org/releases/public/release/fahclient/debian-stable-64bit/v7.5/fahclient_7.5.1_amd64.deb
57-
wget https://download.foldingathome.org/releases/public/release/fahcontrol/debian-stable-64bit/v7.5/fahcontrol_7.5.1-1_all.deb
58-
wget https://download.foldingathome.org/releases/public/release/fahviewer/debian-stable-64bit/v7.5/fahviewer_7.5.1_amd64.deb
62+
wget https://download.foldingathome.org/releases/public/fah-client/debian-10-64bit/release/fah-client_8.4.9_amd64.deb
63+
5964
echo -e "\nInstalling Folding@home"
6065
echo -e "Please enter your password if prompted.\n"
66+
if ! sudo mkdir -p /etc/fah-client; then
67+
echo "Error: Failed to create config directory" >&2
68+
exit 1
69+
fi
6170

62-
# Adapted from: https://www.linuxquestions.org/questions/blog/bittner-195120/howto-automate-interactive-debian-package-installations-debconf-preseeding-2879/
63-
# dpkg-deb -e fahclient_7.5.1_amd64.deb control_files/
64-
# 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
65-
sudo debconf-set-selections <<<"FAHClient fahclient/user string $USERID
66-
FAHClient fahclient/team string $TEAM
67-
FAHClient fahclient/passkey string $PASSKEY
68-
FAHClient fahclient/power select $POWER
69-
FAHClient fahclient/autostart boolean true"
71+
MACHINE_NAME=$HOSTNAME
72+
73+
echo "Generating configuration file..."
74+
if ! sudo bash -c 'cat > /etc/fah-client/config.xml' <<EOF; then
75+
<config>
76+
<user v='$USERID'/>
77+
<team v='$TEAM'/>
78+
<passkey v='$PASSKEY'/>
79+
<power v='$POWER'/>
80+
<account-token v='$TOKEN'/>
81+
<machine-name v='$MACHINE_NAME'/>
82+
</config>
83+
EOF
84+
echo "Error: Failed to write configuration file" >&2
85+
exit 1
86+
fi
87+
sudo dpkg -i --force-depends fah-client_8.4.9_amd64.deb
88+
sudo systemctl restart fah-client
89+
90+
if [[ -z $TOKEN ]]; then
91+
echo "Account Token is not set, edit '/etc/fah-client/config.xml' to add your token."
92+
fi
7093

71-
sudo dpkg -i --force-depends fahclient_7.5.1_amd64.deb
72-
sudo dpkg -i --force-depends fahcontrol_7.5.1-1_all.deb
73-
sudo dpkg -i --force-depends fahviewer_7.5.1_amd64.deb
7494
# sudo apt-get install -f

0 commit comments

Comments
 (0)