-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_automine_ensure_env.sh
executable file
·56 lines (49 loc) · 1.97 KB
/
_automine_ensure_env.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
#!/bin/bash
set -e
if [ -z ${RIG_HOST+x} ]; then
echo "RIG_HOST is unset. Do the following filling in your rig's hostname or ip address"
echo "export RIG_HOST=FILL_THIS_IN"
exit
fi
export AUTOMINE_CFG_PATH=${AUTOMINE_CFG_DIR:=${HOME}/.automine/rig_config}/${RIG_HOST}.automine_config.json
LEGACY_CFG_PATH=cfg/${RIG_HOST}.automine_config.json
if [ ! -f ${AUTOMINE_CFG_PATH} ]; then
if [ -f ${LEGACY_CFG_PATH} ]; then
echo "File not found: ${AUTOMINE_CFG_PATH}"
echo "Instead, it's located at the old location: ${LEGACY_CFG_PATH}"
echo "Do the following:"
echo "1) create the new config dir at $AUTOMINE_CFG_DIR"
echo "2) Move all automine config files at the old location to it"
else
echo "File not found: ${AUTOMINE_CFG_PATH}"
echo "Do the following to create the file:"
echo "cp cfg/127.0.0.1.automine_config.json ${AUTOMINE_CFG_PATH}"
echo "Then edit the file and fill in the relevant values for your rig."
echo "After filling in the values, run this script again."
fi
exit
fi
this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}")
eval $(${this_dir}/show_config.py shell_exports)
# Fail with a useful warning if the deprecated value for $AUTOMINE_ALERT_DIR is set
if [ ! -z "${AUTOMINE_ALERT_DIR}" ] || [ -z ${AUTOMINE_RUNTIME_DIR} ];
then
echo "AUTOMINE_ALERT_DIR is deprecated, instead: "
echo "1) set \$AUTOMINE_RUNTIME_DIR to \$HOME/.automine/var"
echo "2) run ./ssh_reset_rig_env.sh"
exit
fi
# Check if use_public is set either by .automine/.use_public or by environment variable
use_public=0
[[ ${USE_PUBLIC:-'unset'} == "unset" ]] || use_public=1
[[ -f ~/.automine/.use_public ]] && use_public=1
if (( $use_public==1 )); then
SSH_USER="${RIG_USER}@${PUBLIC_HOSTNAME}"
SSH_PORT=${PUBLIC_SSH_PORT:=0}
(( ${SSH_PORT} == 0 )) && SSH_PORT=${LOCAL_SSH_PORT:=22}
else
SSH_USER=${RIG_USER}@${RIG_HOST}
SSH_PORT=${LOCAL_SSH_PORT:=22}
fi
DOWNLOAD_DIR=${HOME}/Downloads/${RIG_TYPE}
[ ${RIG_TYPE} == 'nvidia' ] && ETHASHCUDA=ON || ETHASHCUDA=OFF