-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependencies.sh
78 lines (64 loc) · 1.97 KB
/
dependencies.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
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Default directories (can be overridden by environment variables)
MD4C_DIR="${MD4C_DIR:-md4c}"
BLOG_POSTS_DIR="${BLOG_POSTS_DIR:-/home/${USER}/.config/fifisv}"
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to install a package if it's not already installed
install_if_missing() {
if ! command_exists "$1"; then
echo "Installing $1..."
sudo apt install -y "$1"
else
echo "$1 is already installed."
fi
}
# Cache sudo credentials
sudo -v
# Update package lists
sudo apt update
# Install essential build tools and libraries
install_if_missing build-essential
install_if_missing git
install_if_missing libsqlite3-dev
# Install md4c if not already installed
if ! pkg-config --modversion md4c >/dev/null 2>&1; then
echo "Installing md4c..."
git clone https://github.com/mity/md4c.git "$MD4C_DIR" || { echo "Failed to clone md4c repository"; exit 1; }
cd "$MD4C_DIR"
mkdir -p build && cd build
cmake .. || { echo "cmake configuration failed"; exit 1; }
make || { echo "make failed"; exit 1; }
sudo make install || { echo "make install failed"; exit 1; }
sudo ldconfig
cd ../..
else
echo "md4c is already installed."
fi
# Verify installations
echo "Verifying installations:"
echo "Checking md4c installation:"
if ! pkg-config --modversion md4c; then
echo "md4c installation failed"
exit 1
fi
echo "Installation complete!"
# Clean up
echo "Cleaning up..."
if [ -d "$MD4C_DIR" ]; then
rm -rf "$MD4C_DIR"
echo "$MD4C_DIR directory removed."
else
echo "$MD4C_DIR directory not found. Skipping cleanup."
fi
# Install Fifi's Vault / blog posts
echo "Installing Fifi's Vault / blog posts"
if ! git clone [email protected]:alfredosa/fifisv.git "$BLOG_POSTS_DIR"; then
echo "Failed to clone Fifi's Vault repository"
exit 1
fi
echo "Script execution completed successfully!"