forked from basecamp/omakub
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmigrate.sh
More file actions
86 lines (69 loc) · 2.92 KB
/
migrate.sh
File metadata and controls
86 lines (69 loc) · 2.92 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
80
81
82
83
84
85
#!/bin/bash
set -o pipefail
ascii_art='
██████ ███ ███ █████ ██████ ██ ██ ███ ██ ████████ ██ ██
██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██
██ ██ ██ ████ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██ ██ ██ ██ ██████ ██████ ██ ████ ██ ██████
'
clear
echo -e "\n$ascii_art\n"
sudo apt-get update >/dev/null
sudo apt-get install -y git >/dev/null
# Define migration variables
export OMAKUB_REPO="${OMAKUB_REPO:-omakasui/omabuntu}"
export OMAKUB_REF="${OMAKUB_REF:-main}"
export OMAKUB_BRAND="${OMAKUB_BRAND:-Omabuntu}"
export OMAKUB_MIGRATE="$HOME/.local/share/omakub/install/migrate"
# Define backup location
export BACKUP_DIR="$HOME/.local/share/omakub-backup-$(date +%Y%m%d_%H%M%S)"
# Check Omakub installation
if [[ ! -d $HOME/.local/share/omakub ]]; then
echo "Error: Omakub not found. Please run the installer instead."
exit 1
fi
# Upgrade your system
sudo apt-get update >/dev/null
sudo apt-get upgrade -y >/dev/null
# Check for gum
if ! command -v gum &>/dev/null; then
cd /tmp
wget -q -O gum.deb "https://github.com/charmbracelet/gum/releases/download/v0.17.0/gum_0.17.0_amd64.deb"
sudo apt install -y --allow-downgrades ./gum.deb >/dev/null 2>&1
rm gum.deb
cd - >/dev/null
fi
gum style --border normal --border-foreground 6 --padding "1 2" \
"Ready to migrate to Omabuntu?" \
"" \
"• This migration cannot be stopped once started!" \
"• Make sure you're connected to power or have a full battery" \
"• A backup will be created before proceeding"
echo
# Request confirmation
if ! gum confirm "Continue with migration?"; then
echo "Migration cancelled"
exit 1
fi
# Backup
mkdir -p "$BACKUP_DIR"
cp -r ~/.local/share/omakub "$BACKUP_DIR/omakub" 2>/dev/null || true
cp -f ~/.bashrc "$BACKUP_DIR/bashrc.bak" 2>/dev/null || true
# Clone
echo -e "\nCloning $OMAKUB_BRAND from: https://github.com/${OMAKUB_REPO}.git"
rm -rf ~/.local/share/omakub
git clone https://github.com/$OMAKUB_REPO.git ~/.local/share/omakub >/dev/null 2>/dev/null || {
echo "Clone failed, restoring backup..."
rm -rf ~/.local/share/omakub
cp -r "$BACKUP_DIR/omakub" ~/.local/share/omakub
exit 1
}
# Use custom branch if instructed, otherwise default to main
echo -e "\e[32mUsing branch: $OMAKUB_REF\e[0m"
cd ~/.local/share/omakub
git fetch origin "${OMAKUB_REF}" && git checkout "${OMAKUB_REF}"
cd -
# Migrate
source "$OMAKUB_MIGRATE/all.sh"
source ~/.local/share/omakub/install.sh