|
| 1 | +apiVersion: v1 |
| 2 | +kind: PersistentVolumeClaim |
| 3 | +metadata: |
| 4 | + name: boinc |
| 5 | +spec: |
| 6 | + accessModes: |
| 7 | + - ReadWriteOnce |
| 8 | + resources: |
| 9 | + requests: |
| 10 | + storage: 20Gi |
| 11 | + storageClassName: sata |
| 12 | +--- |
| 13 | +apiVersion: apps/v1 |
| 14 | +kind: Deployment |
| 15 | +metadata: |
| 16 | + name: boinc |
| 17 | +spec: |
| 18 | + replicas: 1 |
| 19 | + selector: |
| 20 | + matchLabels: |
| 21 | + app: boinc |
| 22 | + template: |
| 23 | + metadata: |
| 24 | + labels: |
| 25 | + app: boinc |
| 26 | + spec: |
| 27 | + containers: |
| 28 | + - name: boinc |
| 29 | + image: ubuntu:latest |
| 30 | + command: ["/bin/bash", "-c"] |
| 31 | + env: |
| 32 | + - name: WCG_ACCOUNT_KEY |
| 33 | + value: "YOUR_WCG_ACCOUNT_KEY" # Replace with your actual World Community Grid account key |
| 34 | + - name: RS_ACCOUNT_KEY |
| 35 | + value: "YOUR_RS_ACCOUNT_KEY" # Replace with your actual Rosetta@home account key |
| 36 | + args: |
| 37 | + - | |
| 38 | + set -e # Exit on error |
| 39 | +
|
| 40 | + BOINC_DIR="/boinc" |
| 41 | +
|
| 42 | + # Ensure script runs as root |
| 43 | + if [[ $EUID -ne 0 ]]; then |
| 44 | + echo "This script must be run as root (use sudo)." |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | +
|
| 48 | + # Install dependencies if not present |
| 49 | + echo "Installing dependencies..." |
| 50 | + apt-get update && apt-get install -y git build-essential libssl-dev libcurl4-openssl-dev \ |
| 51 | + libboost-all-dev libsqlite3-dev libwxgtk3.2-dev libwxgtk-webview3.2-dev \ |
| 52 | + autoconf automake libtool pkg-config libgtk-3-dev libnotify-dev \ |
| 53 | + vim sudo wget curl |
| 54 | +
|
| 55 | + # Check if BOINC is already installed |
| 56 | + if [ ! -f "$BOINC_DIR/bin/boinc" ]; then |
| 57 | + echo "BOINC not found. Compiling and installing in $BOINC_DIR..." |
| 58 | + cd /usr/local/src |
| 59 | + git clone https://github.com/BOINC/boinc.git || (cd boinc && git pull) |
| 60 | + cd boinc |
| 61 | + ./_autosetup |
| 62 | + ./configure --prefix="$BOINC_DIR" --disable-server |
| 63 | + make -j$(nproc) |
| 64 | + make install |
| 65 | + else |
| 66 | + echo "BOINC already installed in $BOINC_DIR." |
| 67 | + fi |
| 68 | +
|
| 69 | + # Create the 'boinc' user if it doesn't exist |
| 70 | + if ! id "boinc" &>/dev/null; then |
| 71 | + echo "Creating 'boinc' system user..." |
| 72 | + useradd -r -m -d "$BOINC_DIR" -s /bin/bash boinc |
| 73 | + fi |
| 74 | +
|
| 75 | + # Ensure correct ownership |
| 76 | + echo "Ensuring 'boinc' user owns $BOINC_DIR..." |
| 77 | + chown -R boinc:boinc "$BOINC_DIR" |
| 78 | +
|
| 79 | + # Create the GUI RPC authentication file |
| 80 | + echo "Ensuring GUI RPC authentication file exists..." |
| 81 | + # set your own password if you'd like... this is blank |
| 82 | + echo "" > "$BOINC_DIR/gui_rpc_auth.cfg" |
| 83 | + chown boinc:boinc "$BOINC_DIR/gui_rpc_auth.cfg" |
| 84 | +
|
| 85 | + # Start BOINC, in the background, if not already running |
| 86 | + # This needs to occur to attach projects |
| 87 | + if ! pgrep -u boinc boinc > /dev/null; then |
| 88 | + echo "Starting BOINC client..." |
| 89 | + su - boinc -c "$BOINC_DIR/bin/boinc --dir $BOINC_DIR" & |
| 90 | + sleep 5 |
| 91 | + else |
| 92 | + echo "BOINC client is already running." |
| 93 | + fi |
| 94 | +
|
| 95 | + # Attach to World Community Grid, if not already attached |
| 96 | + if [ ! -f "$BOINC_DIR/account_www.worldcommunitygrid.org.xml" ]; then |
| 97 | + echo "Attaching to World Community Grid using account key..." |
| 98 | + su - boinc -c "$BOINC_DIR/bin/boinccmd --passwd \"\" --project_attach https://www.worldcommunitygrid.org $WCG_ACCOUNT_KEY" |
| 99 | + else |
| 100 | + echo "Already attached to World Community Grid." |
| 101 | + fi |
| 102 | +
|
| 103 | + # Attach to Rosetta@home, if not already attached |
| 104 | + if [ ! -f "$BOINC_DIR/account_boinc.bakerlab.org_rosetta.xml" ]; then |
| 105 | + echo "Attaching to Rosetta@home using account key..." |
| 106 | + su - boinc -c "$BOINC_DIR/bin/boinccmd --passwd \"\" --project_attach https://boinc.bakerlab.org/rosetta $RS_ACCOUNT_KEY" |
| 107 | + else |
| 108 | + echo "Already attached to Rosetta@home." |
| 109 | + fi |
| 110 | + volumeMounts: |
| 111 | + - mountPath: /boinc |
| 112 | + name: boinc-storage |
| 113 | + volumes: |
| 114 | + - name: boinc-storage |
| 115 | + persistentVolumeClaim: |
| 116 | + claimName: boinc |
0 commit comments