-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
76 lines (64 loc) · 2.29 KB
/
update.sh
File metadata and controls
76 lines (64 loc) · 2.29 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
#!/bin/bash
# Define the repository URL
REPO_URL="https://github.com/Eddycrack864/RVC-AI-Cover-Maker-UI"
# Navigate to the directory where the script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR"
# List of directories to keep
declare -a KEEP_DIRS=("env" "logs" "audio_files" "programs/applio_code/rvc/models")
# Function to check if a directory should be kept
should_keep_dir() {
local dir_path="$1"
for keep_dir in "${KEEP_DIRS[@]}"; do
if [[ "$dir_path" == "$keep_dir" ]]; then
return 0 # True, keep it
fi
done
return 1 # False, don't keep it
}
# Delete all directories except the specified ones
for d in *; do
if [ -d "$d" ]; then
IS_KEEP=false
for kp_dir in "${KEEP_DIRS[@]}"; do
# Check for direct matches and parent directories of "programs/applio_code/rvc/models"
if [[ "$d" == "$kp_dir" ]]; then
IS_KEEP=true
break
elif [[ "$kp_dir" == programs/* && "$d" == programs && "$d" != programs/applio_code ]]; then
IS_KEEP=false
break
elif [[ "$kp_dir" == programs/applio_code/* && "$d" == programs/applio_code && "$d" != programs/applio_code/rvc ]]; then
IS_KEEP=false
break
elif [[ "$kp_dir" == programs/applio_code/rvc/* && "$d" == programs/applio_code/rvc && "$d" != programs/applio_code/rvc/models ]]; then
IS_KEEP=false
break
fi
done
if ! $IS_KEEP; then
echo "Deleting directory $d"
rm -rf "$d"
fi
fi
done
# Delete files, excluding the script itself
for f in *; do
if [ -f "$f" ]; then
if [ "$f" != "$(basename "$0")" ]; then # Exclude the script itself
echo "Deleting file $f"
rm -f "$f"
fi
fi
done
# Initialize a new git repository if it doesn't exist
if [ ! -d ".git" ]; then
git init
git remote add origin "$REPO_URL"
fi
# Fetch the latest changes from the repository
git fetch origin
# Reset the working directory to match the latest commit
git reset --hard origin/main
echo "Update complete. Press any key to continue..."
read -n 1 -s # This waits for a single key press without displaying it