-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
79 lines (63 loc) · 2.23 KB
/
bootstrap.sh
File metadata and controls
79 lines (63 loc) · 2.23 KB
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
#!/usr/local/env bash
# Install necessary dependencies
if [[ "$(command -v apt)" ]]; then
sudo apt update
sudo apt upgrade -y
sudo apt install -y git ansible
elif [[ "$(command -v dnf)" ]]; then
sudo dnf upgrade -y
sudo dnf install -y git ansible
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
elif [[ "$(command -v pacman)" ]]; then
sudo pacman -Syu --noconfirm git ansible
else
echo "Unsupported Linux distribution."
exit 1
fi
# Clone the repository
# Define the repository URL and the directory to clone into
REPO_URL="https://github.com/Hugh472/linux-bootstrap.git"
REPO_NAME="linux-bootstrap"
REPO_DIR="$HOME/Documents/$REPO_NAME"
# Check if the repo is cloned somewhere under the home directory
cd /
existing_repo_dir=$(find "$HOME" -type d -path "*/$REPO_NAME/.git" -print -quit)
echo "existing_repo_dir: $existing_repo_dir"
if [[ -n "$existing_repo_dir" ]]; then
echo "Repository found at $existing_repo_dir"
REPO_DIR="$(dirname $existing_repo_dir)"
else
echo "No existing repository found under the home directory."
fi
# Clone or update the repository
if [[ -d "$REPO_DIR/.git" ]]; then
echo "Repository already exists. Pulling the latest changes..."
cd $REPO_DIR
git pull origin main
else
echo "Cloning the repository..."
git clone "$REPO_URL" "$REPO_DIR"
fi
# Navigate to the repo directory
cd "$REPO_DIR" || exit
# Confirm latest changes
pwd
ls -al
git status
echo "Repository is up to date."
# Prompt the user for the GitHub token
read -sp 'Enter your GitHub token: ' GITHUB_TOKEN
echo
# Prompt the user for the GitHub username
read -p 'Enter your GitHub username: ' GITHUB_USERNAME
# Prompt the user for the GitHub email
read -p 'Enter your GitHub email: ' GITHUB_EMAIL
# Export the token as an environment variable
export GITHUB_TOKEN
# Run the Ansible playbook with extra variables
ansible-playbook -c local setup.yml --extra-vars "github_user=${GITHUB_USERNAME} github_email=${GITHUB_EMAIL} kepler=${KEPLER}"
# refresh groups so docker works immediately
sudo su $USER
# tailscale auth
tailscale up