Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
MagicMirrorPiO2W/upgradepm2.sh at master · quasialex/MagicMirrorPiO2W · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
quasialex
MagicMirrorPiO2W
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
MagicMirrorPiO2W
/
upgradepm2.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
51 lines (51 loc) · 1.79 KB
master
Breadcrumbs
MagicMirrorPiO2W
/
upgradepm2.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
51 lines (51 loc) · 1.79 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
mfn=MagicMirror
mac=
$(
uname -s
)
if
[
$mac
==
'
Darwin
'
]
;
then
if
[
"
$(
which greadlink
)
.
"
==
"
.
"
]
;
then
brew install coreutils
fi
cmd=greadlink
else
cmd=readlink
fi
#
put the log where the script is located
logdir=
$(
dirname
$(
$cmd
-f
"
$0
"
)
)
#
if the script was execute from the web
if
[[
$logdir
!=
*
"
MagicMirror/installers
"
*
]]
;
then
#
use the MagicMirror/installers folder
cd
~
/
$mfn
/installers
>
/dev/null
logdir=
$(
pwd
)
cd
-
>
/dev/null
fi
logfile=
$logdir
/upgrade.log
date +
"
PM2 Upgrade started - %a %b %e %H:%M:%S %Z %Y
"
>>
$logfile
if
[
"
$(
which pm2
)
.
"
!=
"
.
"
]
;
then
pm2_npmjs_version=
$(
npm view pm2 version
)
pm2_current_version=
$(
npm list -g --depth=0
|
grep -i pm2
|
awk -F@
'
{print $2}
'
)
echo
pm2 installed, checking version
$pm2_current_version
vs
$pm2_npmjs_version
>>
$logfile
if
[ 1
-o
"
${pm2_npmjs_version
:
0
:
1}
.
"
==
"
${pm2_current_version
:
0
:
1}
.
"
-a
"
$pm2_current_version
.
"
!=
"
$pm2_npmjs_version
.
"
]
;
then
#
if pm2 is managing MagicMirror,, then update
if
[
$(
pm2 ls -m
|
grep
"
\-\-
"
|
grep -i magicmirror
|
wc -l
)
-eq
1 ]
;
then
apps_defined=
$(
pm2 ls -m
|
grep
"
\-\-
"
|
wc -l
)
echo
pm2 same major version, so updating
>>
$logfile
sudo npm install pm2@latest -g
2>&1
>>
$logfile
pm2 update
2>&1
>>
$logfile
rc=
$?
if
[
$rc
-eq
0 ]
;
then
apps_defined_after_update=
$(
pm2 ls -m
|
grep
"
\-\-
"
|
wc -l
)
if
[
$apps_defined
!=
$apps_defined_after_update
]
;
then
echo
rerunning pm2 update , after app count incorrect
>>
$logfile
pm2 update
2>&1
>>
$logfile
fi
echo
pm2 update completed
>>
$logfile
else
echo
pm2 update failed, rc=
$rc
|
tee -a
$logfile
fi
else
echo
not managing pm2
>>
$logfile
fi
else
echo
no pm2 required
>>
$logfile
fi
fi
date +
"
PM2 Upgrade ended - %a %b %e %H:%M:%S %Z %Y
"
>>
$logfile
You can’t perform that action at this time.