-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·128 lines (109 loc) · 3.66 KB
/
run.sh
File metadata and controls
executable file
·128 lines (109 loc) · 3.66 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
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
#!/bin/bash
# Check if Git is installed
if ! command -v git &>/dev/null; then
echo "Error: Git is not installed on your system."
echo "Please install Git first:"
echo " - For Ubuntu/Debian: sudo apt-get install git"
echo " - For CentOS/RHEL: sudo yum install git"
echo " - For macOS: brew install git"
echo " - For Windows: Download from https://git-scm.com/downloads"
exit 1
fi
# Check if it's a Git repository
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
echo "Not a Git repository. Auto-update not possible."
else
# Fetch the latest tags from the remote repository
git fetch --tags
# Get the latest version tag (must start with V)
latest_tag=$(git tag -l "V*" | sort -V | tail -n1)
if [ -z "$latest_tag" ]; then
echo "No version tags (starting with V) found on server, could not check for updates."
else
# Get current commit hash
current_commit=$(git rev-parse HEAD)
# Get commit hash of the latest tag
tag_commit=$(git rev-parse "$latest_tag^{}")
# Get tag creation date
tag_date=$(git log -1 --format=%ai "$latest_tag")
echo "Latest version: $latest_tag"
echo "Created on: $tag_date"
if [ "$current_commit" = "$tag_commit" ]; then
echo "Already running the latest version ($latest_tag)"
else
# Ask for confirmation
read -p "Do you want to proceed and update to this version? (y/n) " answer
if [[ $answer == "y" || $answer == "Y" ]]; then
# Switch to the latest tag
git checkout "$latest_tag"
# Optional: Ensure the latest updates from the remote repository
git pull origin "$latest_tag"
echo "Updated to version $latest_tag successfully."
else
echo "Continuing with current version..."
fi
fi
fi
fi
# Check if ".venv" folder exists, if not create a virtual environment
if [ ! -d ".venv" ]; then
echo "Creating virtual environment..."
python3 -m venv .venv
else
echo "Virtual environment already exists."
fi
# Activate the virtual environment
source .venv/bin/activate
# # Check if "models/toony.safetensors" exists, if not download it
# if [ ! -f "models/toonify.safetensors ]; then
# echo "Downloading toony.safetensors..."
# mkdir -p models
# wget -O models/toonify.safetensors "https://civitai.com/api/download/models/244831?type=Model&format=SafeTensor&size=pruned&fp=fp16"
# else
# echo "Model file already exists."
# fi
# Upgrade Python requirements
echo "Upgrading Python requirements..."
pip install --quiet --upgrade pip
pip install --quiet --require-virtualenv --requirement requirements.txt
# download the correct model (TODO: use config in future)
ollama pull artifish/llama3.2-uncensored
# Function to start the main app
start_main_app() {
echo "Starting App..."
python main.py
}
# Function to start the analytics dashboard
start_analytics() {
echo "Starting Telegram Bot..."
python analytics_dashboard.py
}
# Function to start both components
start_both() {
echo "Starting both App and Bot..."
python main.py &
python analytics_dashboard.py &
wait
}
# Show menu and get user choice
echo "Please select what to start:"
echo "1) AI App"
#echo "2) Analytics Dashboard"
#echo "3) Both"
read -p "Enter your choice (1): " choice
case $choice in
1)
start_main_app
;;
2)
start_analytics
;;
3)
start_both
;;
*)
echo "Invalid choice. Starting app by default..."
start_main_app
;;
esac
# Deactivate the virtual environment when done