-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
executable file
·229 lines (174 loc) · 5.69 KB
/
install.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/usr/bin/env bash
#####################################################
#### Installation script for Debian based systems ###
#####################################################
# check if conda is installed
if ! command -v conda &> /dev/null
then
echo
read -p "Install miniconda? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
# download latest miniconda for linux install script
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# verify hash
sha256sum Miniconda3-latest-Linux-x86_64.sh
# install miniconda
bash Miniconda3-latest-Linux-x86_64.sh
else
echo "Please install miniconda and run this script again."
exit 1
fi
fi
source ~/.bashrc
# initialize shell for conda
conda init bash
##############################
### RabbitMQ installation ####
##############################
# check if rabbitmq is installed
if ! command -v rabbitmq-server &> /dev/null
then
echo
read -p "Install rabbitmq-server? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo
read -p "Install RabbitMQ from apt? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
# install rabbitmq
sudo apt-get install rabbitmq-server
# start rabbitmq
sudo systemctl start rabbitmq-server
# enable rabbitmq service
sudo systemctl enable rabbitmq-server
fi
else
echo "Please install rabbitmq-server and run this script again."
exit 1
fi
fi
######################################
### stable diffusion installation ####
######################################
echo
read -p "Install stable diffusion? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Where would you like to clone stable-diffusion?"
# get input from user
echo
read -p "Path: " path_for_clone
echo
# add stable-diffusion to path_for_clone
path_for_clone="$path_for_clone/stable-diffusion"
if [ -d "$path_for_clone" ]; then
echo
echo "Directory already exists"
echo
read -p "Would you like to overwrite it? (y/n): " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "$path_for_clone"
fi
fi
# clone stable-diffusion
if ! [ -d "$path_for_clone" ]; then
git clone --branch feature/add-classes https://github.com/w4ffl35/stable-diffusion.git "$path_for_clone"
fi
# change directory to stable-diffusion
cd "$path_for_clone"
cd stable_diffusion
# create virtual environment
# ask user if they want to user virtual environment
echo
read -p "Standard stable-diffusion installation? [y/n]: " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
conda env create -f environment.yaml
conda activate ldm
else
echo "Skipping virtual environment creation..."
fi
fi
######################################
### stablediffusiond installation ####
######################################
echo
read -p "Install stablediffusiond? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# append stablediffusiond to .git/info/exclude if it doesn't already exist
if ! grep -q "stablediffusiond" .git/info/exclude; then
echo "stablediffusiond" >> .git/info/exclude
fi
echo
read -p "Path: " path_for_clone
echo
# clone stablediffusiond
git clone https://github.com/w4ffl35/stablediffusiond.git
# change directory to stablediffusiond
cd stablediffusiond
# install stablediffusiond requirements
pip install -r requirements.txt
# copy settings.default.py to settings.py
cp settings.default.py settings.py
fi
############################
### bin directory setup ####
############################
echo
read -p "Setup bin directory? (y/n) " -n 1 -r
echo
# Add bin directory to .bashrc PATH
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo ln -s "$PWD/bin/client.sh" "/usr/local/bin/stablediffusion_client"
fi
######################################
### stablediffusiond daemon setup ####
######################################
echo
read -p "Setup stablediffusiond daemon? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
# copy etc/stablediffusiond.service to /etc/systemd/system
sudo cp etc/stablediffusiond.service /etc/systemd/system
# change [USER_HERE] to current user
sudo sed -i "s/\[USER_HERE\]/$(whoami)/g" /etc/systemd/system/stablediffusiond.service
# change PATH_TO_STABLEDIFFUSIOND to current path
sudo sed -i "s|PATH_TO_STABLEDIFFUSIOND|$PWD|g" /etc/systemd/system/stablediffusiond.service
# enable stablediffusiond.service
sudo systemctl enable stablediffusiond.service
# start stablediffusiond.service
sudo systemctl start stablediffusiond.service
# check status of stablediffusiond.service
sudo systemctl status stablediffusiond.service
fi
###############################################
### stablediffusion_responsed daemon setup ####
###############################################
echo
read -p "Setup stablediffusion_responsed daemon? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
# copy etc/stablediffusion_responsed.service to /etc/systemd/system
sudo cp etc/stablediffusion_responsed.service /etc/systemd/system
# change [USER_HERE] to current user
sudo sed -i "s/\[USER_HERE\]/$(whoami)/g" /etc/systemd/system/stablediffusion_responsed.service
# change PATH_TO_STABLEDIFFUSIOND to current path
sudo sed -i "s|PATH_TO_STABLEDIFFUSIOND|$PWD|g" /etc/systemd/system/stablediffusiond.service
# enable stablediffusion_responsed.service
sudo systemctl enable stablediffusion_responsed.service
# start stablediffusion_responsed.service
sudo systemctl start stablediffusion_responsed.service
# check status of stablediffusion_responsed.service
sudo systemctl status stablediffusion_responsed.service
fi
echo "Installation complete!"