generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
74 lines (65 loc) · 1.94 KB
/
setup.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
71
72
73
74
#!/bin/bash
# Set directories and file paths based on the operating system
DRPM_DIR="drpm"
CONFIG_DRPM_DIR=""
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
CONFIG_DRPM_DIR="${APPDATA:-$HOME/AppData/Roaming}/$DRPM_DIR"
else
CONFIG_DRPM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/$DRPM_DIR"
fi
DRPM_REGISTRYPID_FILE="$CONFIG_DRPM_DIR/registry.pid"
DRPM_REGISTRY_OUT_FILE="$CONFIG_DRPM_DIR/registry.out"
DRPM_PROFILE="$CONFIG_DRPM_DIR/profile.json"
DRPM_VERSION_FILE="$CONFIG_DRPM_DIR/.version"
# Ensure CONFIG_DRPM_DIR exists
if [[ ! -d "$CONFIG_DRPM_DIR" ]]; then
mkdir -p "$CONFIG_DRPM_DIR"
echo "DRPM config created ($CONFIG_DRPM_DIR)"
fi
# Ensure DRPM_REGISTRYPID_FILE exists
if [[ ! -f "$DRPM_REGISTRYPID_FILE" ]]; then
touch "$DRPM_REGISTRYPID_FILE"
echo "DRPM registry.pid created: $DRPM_REGISTRYPID_FILE"
fi
# Ensure DRPM_REGISTRY_OUT_FILE exists
if [[ ! -f "$DRPM_REGISTRY_OUT_FILE" ]]; then
touch "$DRPM_REGISTRY_OUT_FILE"
echo "DRPM registry.out created: $DRPM_REGISTRY_OUT_FILE"
fi
# Ensure DRPM_VERSION_FILE exists
if [[ ! -f "$DRPM_VERSION_FILE" ]]; then
VERSION=$(jq -r '.version' package.json || echo "4.2.3")
echo "$VERSION" >> "$DRPM_VERSION_FILE"
echo "DRPM .version created: $DRPM_VERSION_FILE"
fi
# Ensure DRPM_PROFILE exists, and create it with default JSON content if it doesn’t
if [[ ! -f "$DRPM_PROFILE" ]]; then
cat << EOF > "$DRPM_PROFILE"
{
"current": null,
"dht": {
"did": "",
"dwnEndpoints": [],
"web5DataPath": "",
"password": "",
"recoveryPhrase": ""
},
"web": {
"did": "",
"dwnEndpoints": [],
"web5DataPath": "",
"password": "",
"recoveryPhrase": ""
},
"btc": {
"did": "",
"dwnEndpoints": [],
"web5DataPath": "",
"password": "",
"recoveryPhrase": ""
}
}
EOF
echo "DRPM profile.json created: $DRPM_PROFILE"
fi
echo "DRPM Setup Complete!"