forked from VictoryLinux/VictoryNixos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·218 lines (183 loc) · 6.39 KB
/
setup.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
#!/usr/bin/env bash
# Docker Update script for NixOS
# Ver. 1.3
#####################################################################
# ____ ____ __ #
# \ \ / / |__| ____ ________ ____ _______ ___ ___ #
# \ \/ / ___ | _|\__ __\ / _ \ | __ |\ \/ / #
# \ / | || |_ | | | |_| || | |__| \ / #
# \____/ |___||____| |__| \_____ / |__| |_| #
# #
# Victory Tek Install script #
# https://github.com/Victorytek #
#####################################################################
# Make sure each command executes properly
clear
check_exit_status() {
if [ $? -eq 0 ]
then
echo
echo "Success"
echo
else
echo
echo "[ERROR] Update Failed! Check the errors and try again"
echo
read -p "The last command exited with an error. Exit script? (y/n) " answer
if [ "$answer" == "y" ]
then
exit 1
fi
fi
}
function greeting() {
echo -e "+-----------------------------------------------------------------+"
echo -e " Hello, $USER. Welcome to Victory Scripts. "
echo -e "+ +"
echo -e "+ You are attempting to Setup +"
echo -e "+ +"
echo -e "+ NixOS +"
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
# sleep 5s
echo "ARE YOU READY TO START? [y,n]"
read input
# did we get an input value?
if [ "$input" == "" ]; then
echo "Nothing was entered by the user"
# was it a y or a yes?
elif [[ "$input" == "y" ]] || [[ "$input" == "yes" ]]; then
echo "You replied $input, you are ready to start"
echo
echo "Starting NixOS Update script."
echo
sleep 3s
# treat anything else as a negative response
else
echo "You replied $input, you are not ready"
echo
exit 1
fi
echo
check_exit_status
}
# make and move
function move() {
echo
sudo mkdir /etc/nixos/modules
echo
sudo mkdir /etc/nixos/modules/de
sudo mkdir /etc/nixos/modules/installs
sudo mkdir /etc/nixos/modules/network
sudo mkdir /etc/nixos/modules/services
sudo mkdir /etc/nixos/modules/system
sudo mkdir /etc/nixos/secrets
echo
sudo mv -i /home/$USER/Nixos/modules/gnome.nix /etc/nixos/modules/de
sudo mv -i /home/$USER/Nixos/modules/gnome_extensions.nix /etc/nixos/modules/installs
sudo mv -i /home/$USER/Nixos/modules/packages.nix /etc/nixos/modules/installs
sudo mv -i /home/$USER/Nixos/modules/rustdesk.nix /etc/nixos/modules/installs
sudo mv -i /home/$USER/Nixos/modules/virtualbox-ga.nix /etc/nixos/modules/installs
sudo mv -i /home/$USER/Nixos/modules/uptime-kuma.nix /etc/nixos/installs
sudo mv -i /home/$USER/Nixos/modules/dhcp.nix /etc/nixos/modules/network
sudo mv -i /home/$USER/Nixos/modules/static.nix /etc/nixos/modules/network
sudo mv -i /home/$USER/Nixos/modules/flatpak.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/docker.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/podman.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/plex.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/jellyfin.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/print.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/smb.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/sound.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/ssh.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/tailscale.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/traefik.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/qemu_kvm.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/virtualbox.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/xrdp.nix /etc/nixos/modules/services
sudo mv -i /home/$USER/Nixos/modules/cleanup.nix /etc/nixos/modules/system
sudo mv -i /home/$USER/Nixos/modules/flakes-enabled.nix /etc/nixos/modules/system
sudo mv -i /home/$USER/Nixos/modules/nur.nix /etc/nixos/modules/system
sudo mv -i /home/$USER/Nixos/modules/users.nix /etc/nixos/modules/system
sudo mv -i /home/$USER/Nixos/update.sh /home/$USER/Documents
sudo mv -i /home/$USER/Nixos/Version_Upgrade.sh /home/$USER/Documents
sudo mv -i /home/$USER/Nixos/modules/smb-data /etc/nixos/secrets
sudo mv -i /home/$USER/Nixos/modules/smb-mydata /etc/nixos/secrets
echo
echo "NixOS modules have been placed"
echo
check_exit_status
}
# Stop the running container
function secrets() {
echo
sudo chmod 0600 /etc/nixos/secrets/smb-data
sudo chmod 0600 /etc/nixos/secrets/smb-mydata
echo
sudo mv -i /etc/nixos/secrets /etc/nixos/.secrets
echo
check_exit_status
}
# Change configs and activate modules
function config() {
sudo mv -i /etc/nixos/configuration.nix /etc/nixos/configuration.nix.old
echo
sudo mv -i ~/Nixos/configuration.nix /etc/nixos
echo
sleep 3s
echo
sudo nano /etc/nixos/configuration.nix
echo
echo "NixOS configuration has been changed and configured."
echo
check_exit_status
}
# Stop the running container
function update() {
sudo nix-channel --update
echo
echo "Stable Channel Updated"
echo
check_exit_status
}
# Remove the container
function upgrade() {
sudo nixos-rebuild switch
echo
echo "Nixos updated"
echo
check_exit_status
}
# Reboot
function reboot() {
echo "Do you want to restart? [y,n]"
read input
# did we get an input value?
if [ "$input" == "" ]; then
echo "Nothing was entered by the user"
# was it a y or a yes?
elif [[ "$input" == "y" ]] || [[ "$input" == "yes" ]]; then
echo "You replied $input, rebooting"
echo
sleep 3s
# treat anything else as a negative response
else
echo "You replied $input, not rebooting"
echo
exit 1
fi
echo
shutdown --reboot 1
echo
echo "Rebooting in 1 minute"
echo
sleep 90
echo
check_exit_status
}
greeting
move
secrets
config
update
upgrade
reboot