forked from BELABOX/belaUI
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
102 lines (78 loc) · 3.03 KB
/
install.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# Install script to install the belaUI fork on a BELABOX
# Variables
USE_CERAUI=${USE_CERAUI:-false}
RELEASE_TARBALL="belaUI.tar.xz"
RELEASE_URL="https://github.com/pjeweb/belaUI/releases/latest/download/$RELEASE_TARBALL"
CERAUI_RELEASE_TARBALL="ceraui-extended.tar.xz"
CERAUI_RELEASE_URL="https://github.com/CERALIVE/CeraUI/releases/latest/download/$CERAUI_RELEASE_TARBALL"
TEMP_DIR="$HOME/.tmp/belaui"
TARGET_DIR="/opt/belaUI"
# Check if dependencies are installed
JQ_INSTALLED=$(jq --version 2>/dev/null) || false
RSYNC_INSTALLED=$(rsync --version 2>/dev/null) || false
# stop on error
set -e
if [ -z "$JQ_INSTALLED" ] || [ -z "$RSYNC_INSTALLED" ]; then
echo "Installing missing dependencies"
sudo apt-get update
sudo apt-get install -y rsync jq
fi
# Clone the repository branch into a temporary directory
if [ -d "$TEMP_DIR" ]; then
rm -rf "$TEMP_DIR"
fi
# Install latest release from tarball to temporary directory
echo "Downloading and extracting latest release"
mkdir -p "$TEMP_DIR"
cd "$TEMP_DIR" || exit
wget -q --show-progress $RELEASE_URL
tar xf $RELEASE_TARBALL
# Ensure target directory exists
mkdir -p $TARGET_DIR
# Copy files from dist to target directory while excluding specified files
echo "Installing belaUI"
sudo rsync -rltz --delete --chown=root:root \
--exclude auth_tokens.json \
--exclude config.json \
--exclude dns_cache.json \
--exclude gsm_operator_cache.json \
--exclude relays_cache.json \
--exclude revision \
--exclude setup.json \
"$TEMP_DIR/" $TARGET_DIR
# Cleanup
rm -rf "$TEMP_DIR"
# Set ownership to root:root and preserve permissions
sudo chown -R root:root $TARGET_DIR
# Add moblink_relay_enabled: true to setup.json
echo "Enabling Moblink Relay. You can disable it in $TARGET_DIR/setup.json"
sudo cp $TARGET_DIR/setup.json $TARGET_DIR/setup.json.tmp
# Enable moblink relay and set path to moblink-rust-relay
sudo jq '.moblink_relay_enabled = true | .moblink_relay_bin = "/opt/moblink-rust-relay/target/release/moblink-rust-relay"' $TARGET_DIR/setup.json.tmp | sudo tee $TARGET_DIR/setup.json > /dev/null
sudo rm $TARGET_DIR/setup.json.tmp
# Install moblink-rust-relay
cd $TARGET_DIR || exit
sudo bash ./install-moblink-rust-relay.sh
echo "Moblink relay installed successfully."
# Run the override script
cd $TARGET_DIR || exit
sudo bash ./override-belaui.sh
echo "BelaUI installed and override script executed successfully."
# Check if CeraUI should be installed
if [ "$USE_CERAUI" = "true" ]; then
echo "Downloading and installing CeraUI content"
# Create a temporary directory for CeraUI
CERAUI_TEMP_DIR="$HOME/.tmp/ceraui"
mkdir -p "$CERAUI_TEMP_DIR"
cd "$CERAUI_TEMP_DIR" || exit
# Download and extract CeraUI
wget -q --show-progress $CERAUI_RELEASE_URL
tar xf $CERAUI_RELEASE_TARBALL
# Replace the content of the public folder
sudo rsync -rltz --delete --chown=root:root "$CERAUI_TEMP_DIR/" "$TARGET_DIR/public/"
# Cleanup
rm -rf "$CERAUI_TEMP_DIR"
echo "CeraUI installed successfully."
fi
echo "You can reset to default by running: sudo $TARGET_DIR/reset-to-default.sh"