-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsysupdater.fish
170 lines (151 loc) · 4.38 KB
/
sysupdater.fish
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
#!/usr/env fish
# from herrbischoff/fish-osx
# Update functions
function __freebsd_portmaster
printf "\n====[ Upgrade Software ] ===================================\n"; and \
sudo portmaster -aBd; and \
sudo portmaster -y --clean-distfiles
end
function __freebsd_pkg
printf "\n====[ Upgrade Software ] ===================================\n"; and \
sudo pkg update; and \
sudo pkg upgrade
end
function __freebsd_synth
printf "\n====[ Compile and Upgrade Software ]========================\n"; and \
sudo synth upgrade-system
end
function __freebsd_portsnap
printf "\n====[ Update Ports tree ]===================================\n"; and \
sudo portsnap fetch update
end
function __freebsd_ezjail_ports
set cmd (which ezjail-admin)
if test $status -eq 0
printf "\n====[ Update ezjail Ports tree ]============================\n"; and \
sudo ezjail-admin update -P
end
end
function __freebsd_freebsd-update
printf "====[ System Software Update ]==============================\n"; and \
sudo freebsd-update fetch; and \
sudo freebsd-update install
end
function __freebsd_source
printf "====[ Update System Sources ]===============================\n"; and \
sudo svnlite update /usr/src
end
function __update_node_packages
set cmd (which npm)
set os (uname)
if test $status -eq 0
printf "\n====[ npm ]=================================================\n"
if [ $os = "Darwin" ]
npm -g upgrade
else
sudo npm -g upgrade
end
end
set cmd (which yarn)
if test $status -eq 0
printf "\n====[ yarn ]================================================\n"; and \
yarn global upgrade
end
set -e cmd
set -e os
end
function __update_gems
if test -d $HOME/.rvm/bin
printf "====[ Gems ]================================================\n"; and \
gem update; and \
gem cleanup
end
end
function __macos_software_update
printf "\n====[ Apple Software Update ]===============================\n"; and \
sudo softwareupdate -i -a
end
function __macos_appstore
set cmd (which mas)
if test $status -eq 0
printf "\n====[ App Store ]===========================================\n"; and \
mas upgrade
end
set -e cmd
end
function __macos_macports
set cmd (which port)
if test $status -eq 0
printf "\n====[ MacPorts ]============================================\n"; and \
sudo port selfupdate; and \
sudo port outdated; and \
sudo port upgrade outdated; and \
sudo port uninstall leaves
port uninstall inactive
end
set -e cmd
end
function __macos_homebrew
set cmd (which brew)
if test $status -eq 0
printf "\n====[ Homebrew ]============================================\n"; and \
brew update; and \
brew upgrade --cleanup; and \
# brew upgrade --fetch-HEAD universal-ctags; and \
brew cleanup -s; and \
brew prune
end
set -e cmd
end
function __update_pip
set cmd (python -m pip_review --help)
if test $status -eq 0
printf "\n====[ pip ]=================================================\n"; and \
python -m pip_review --auto
end
set -e cmd
end
function __debian_apt
printf "\n====[ apt-get ]=============================================\n"; and \
sudo apt update; and \
sudo apt upgrade
end
#####
function sysupdater --description 'Update system software'
switch (uname)
case Darwin
__macos_software_update
__macos_appstore
__macos_homebrew
__update_node_packages
__update_gems
__update_pip
case Linux
__debian_apt
__update_node_packages
# __update_gems
# __update_pip
case FreeBSD
if [ "$argv[1]" = "jail" ]
__freebsd_portmaster
__update_node_packages
# __update_gems
# __update_pip
# else if [ (uname -p) = "armv6" ]
# __freebsd_portsnap
# __freebsd_portmaster
# __update_npm
# __update_gems
# __update_pip
else
__freebsd_portsnap
__freebsd_ezjail_ports
__freebsd_pkg
__update_node_packages
# __update_gems
# __update_pip
end
case '*'
printf "No update function for %s yet." (uname)
end
end