-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
168 lines (124 loc) · 4.26 KB
/
installer.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
set -euo pipefail
# Track current step for error reporting
CURRENT_STEP="Starting script"
# Error handler
trap 'echo -e "\n❌ Error during: $CURRENT_STEP\n"; exit 1' ERR
# --- Functions ---
log() {
echo -e "\n🔹 $1"
}
install_dependencies() {
CURRENT_STEP="Installing system dependencies"
log "Installing base dependencies..."
sudo apt update
sudo apt install -y \
python3 python3-venv python3-pip flac abcde flatpak \
build-essential pkg-config libc6-dev libssl-dev \
libexpat1-dev libavcodec-dev libgl1-mesa-dev \
qtbase5-dev zlib1g-dev
}
install_lact() {
CURRENT_STEP="Installing LACT"
log "Installing LACT..."
local REPO="ilya-zlobintsev/LACT"
local API_URL="https://api.github.com/repos/$REPO/releases/latest"
if ! command -v apt &> /dev/null; then
echo "This script is intended for Debian-based systems (Ubuntu, Debian, etc.)"
return 1
fi
. /etc/os-release
DISTRO=$ID
VERSION_ID=${VERSION_ID//\"/}
VERSION_SIMPLE=$(echo "$VERSION_ID" | tr -d '.')
echo "Detected system: $DISTRO $VERSION_ID"
if [[ "$DISTRO" != "ubuntu" && "$DISTRO" != "debian" ]]; then
echo "Unsupported distro: $DISTRO"
return 1
fi
RELEASE_JSON=$(curl -s "$API_URL")
DEB_URLS=$(echo "$RELEASE_JSON" | grep "browser_download_url" | grep "\.deb" | cut -d '"' -f 4)
MATCHED_URL=""
for url in $DEB_URLS; do
if [[ "$url" == *"$DISTRO-$VERSION_SIMPLE.deb" ]]; then
MATCHED_URL="$url"
break
fi
done
if [ -z "$MATCHED_URL" ]; then
log "Exact match not found. Looking for closest match..."
MATCHED_URL=$(echo "$DEB_URLS" | grep "$DISTRO" | sort -V | tail -n 1)
fi
if [ -z "$MATCHED_URL" ]; then
echo "No suitable .deb package found."
return 1
fi
FILENAME=$(basename "$MATCHED_URL")
curl -LO "$MATCHED_URL"
sudo apt install -y "./$FILENAME"
rm "$FILENAME"
log "LACT installed successfully."
}
install_makemkv() {
CURRENT_STEP="Installing MakeMKV from forum-sourced URLs"
log "Fetching latest MakeMKV download links from forum..."
FORUM_URL="https://forum.makemkv.com/forum/viewtopic.php?t=224"
PAGE_CONTENT=$(curl -s "$FORUM_URL")
# Extract the latest OSS and BIN URLs
OSS_URL=$(echo "$PAGE_CONTENT" | grep -oP 'https://www.makemkv.com/download/makemkv-oss-[0-9.]+\.tar\.gz' | head -n 1)
BIN_URL=$(echo "$PAGE_CONTENT" | grep -oP 'https://www.makemkv.com/download/makemkv-bin-[0-9.]+\.tar\.gz' | head -n 1)
if [[ -z "$OSS_URL" || -z "$BIN_URL" ]]; then
echo "❌ Failed to extract MakeMKV download URLs."
return 1
fi
# Extract version number from OSS URL
VERSION=$(echo "$OSS_URL" | grep -oP '[0-9]+\.[0-9]+\.[0-9]+')
log "Found MakeMKV version: $VERSION"
log "Downloading OSS and BIN tarballs..."
curl -LO "$OSS_URL"
curl -LO "$BIN_URL"
# Extract archives
tar xzf "makemkv-oss-$VERSION.tar.gz"
tar xzf "makemkv-bin-$VERSION.tar.gz"
# Compile OSS
pushd "makemkv-oss-$VERSION"
./configure
make
sudo make install
popd
# Compile BIN
pushd "makemkv-bin-$VERSION"
make
sudo make install
popd
rm -rf "makemkv-oss-$VERSION" "makemkv-bin-$VERSION"
rm "makemkv-oss-$VERSION.tar.gz" "makemkv-bin-$VERSION.tar.gz"
log "✅ MakeMKV $VERSION installed successfully."
}
install_makemkv_key() {
CURRENT_STEP="Fetching MakeMKV beta key from cable.ayra.ch"
log "Fetching MakeMKV beta key..."
BETA_KEY=$(curl -s "https://cable.ayra.ch/makemkv/api.php?raw")
if [[ -z "$BETA_KEY" ]]; then
echo "❌ Failed to fetch a valid MakeMKV beta key."
return 1
fi
log "Fetched beta key: $BETA_KEY"
# Ensure MakeMKV config dir exists
mkdir -p ~/.MakeMKV
CONFIG_FILE=~/.MakeMKV/settings.conf
# Add or update the app_Key
if grep -q "^app_Key" "$CONFIG_FILE" 2>/dev/null; then
sed -i "s|^app_Key.*|app_Key = $BETA_KEY|" "$CONFIG_FILE"
else
echo "app_Key = $BETA_KEY" >> "$CONFIG_FILE"
fi
log "Beta key saved to $CONFIG_FILE"
}
# --- Main ---
log "Beginning full setup process..."
install_dependencies
install_lact
install_makemkv
install_makemkv_key
log "✅ Setup complete!"