forked from VictoryLinux/VictoryNixos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·155 lines (121 loc) · 3.26 KB
/
update.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
#!/usr/bin/env bash
# Docker Update script for NixOS
# Ver. 1.4
#####################################################################
# ____ ____ __ #
# \ \ / / |__| ____ ________ ____ _______ ___ ___ #
# \ \/ / ___ | _|\__ __\ / _ \ | __ |\ \/ / #
# \ / | || |_ | | | |_| || | |__| \ / #
# \____/ |___||____| |__| \_____ / |__| |_| #
# #
# 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 Update +"
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
}
# Sync with the update channel
function channel() {
sudo nix-channel --update
echo
echo "Stable Channel Updated"
echo
check_exit_status
}
# Update
function update() {
sudo nixos-rebuild switch
echo
echo "Nixos updated"
echo
check_exit_status
}
# Reboot automatically
function auto_reboot() {
echo
shutdown --reboot 1
echo
echo "Rebooting in 1 minute"
echo
sleep 90
echo
check_exit_status
}
# Reboot Ask
function ask_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
sudo shutdown --reboot 1
echo
echo "Rebooting in 1 minute"
echo
sleep 90
echo
check_exit_status
}
greeting
channel
update
#auto_reboot
ask_reboot