Skip to content

Commit 5d65ccc

Browse files
authored
Merge pull request #32 from Josef-MrBeam/stable
Stable
2 parents e35db1a + 0f2f6b7 commit 5d65ccc

25 files changed

+416
-80
lines changed

octoprint_mrbeam/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ def get_assets(self):
709709
"js/calibration/watterott/camera_alignment.js",
710710
"js/calibration/watterott/calibration_qa.js",
711711
"js/calibration/watterott/label_printer.js",
712+
"js/hard_refresh_overlay.js",
712713
],
713714
css=[
714715
"css/mrbeam.css",

octoprint_mrbeam/files/migrate_logrotate/analytics

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
/home/pi/.octoprint/analytics/analytics_log.json {
55
size 100M
6-
rotate 2
6+
rotate 3
77
compress
88
delaycompress
99
missingok
1010
notifempty
11+
dateext
12+
dateformat .%Y-%m-%d
1113
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/var/log/iobeam.log {
22
size 2M
3-
rotate 4
3+
rotate 3
44
compress
55
delaycompress
66
missingok
77
notifempty
88
copytruncate
9+
dateext
10+
dateformat .%Y-%m-%d
911
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/var/log/mount_manager.log {
22
size 2M
3-
rotate 2
3+
rotate 3
44
compress
55
delaycompress
66
missingok
77
notifempty
88
copytruncate
99
create 644 root root
10+
dateext
11+
dateformat .%Y-%m-%d
1012
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/var/log/mrb_check.log {
22
size 5M
3-
rotate 4
3+
rotate 3
44
compress
55
delaycompress
66
missingok
77
notifempty
88
copytruncate
99
create 644 root root
10+
dateext
11+
dateformat .%Y-%m-%d
1012
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/var/log/mrbeam_ledstrips.log {
22
size 2M
3-
rotate 2
3+
rotate 3
44
compress
55
delaycompress
66
missingok
77
notifempty
88
copytruncate
99
create 644 root root
10+
dateext
11+
dateformat .%Y-%m-%d
1012
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/var/log/netconnectd.log {
22
size 2M
3-
rotate 2
3+
rotate 3
44
compress
55
delaycompress
66
missingok
77
notifempty
88
copytruncate
9+
dateext
10+
dateformat .%Y-%m-%d
911
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import os
2+
3+
from octoprint_mrbeam.migration.migration_base import (
4+
MigrationBaseClass,
5+
)
6+
7+
8+
class Mig003EnableLogrotateBuster(MigrationBaseClass):
9+
"""
10+
This migration should add logrotate for the buster image and change the lorotate for the legacy image
11+
"""
12+
13+
MIGRATE_LOGROTATE_FOLDER = "files/migrate_logrotate/"
14+
BEAMOS_VERSION_LOW = "0.14.0"
15+
BEAMOS_VERSION_HIGH = "0.18.2"
16+
17+
def __init__(self, plugin):
18+
super(Mig003EnableLogrotateBuster, self).__init__(plugin)
19+
20+
@property
21+
def id(self):
22+
return "003"
23+
24+
def _run(self):
25+
self._logger.debug("delete wrong iobeam logrotate")
26+
self.exec_cmd("sudo rm /etc/logrotate.d/iobeam.logrotate", optional=True)
27+
28+
logrotates = [
29+
"analytics",
30+
"iobeam",
31+
"mount_manager",
32+
"mrb_check",
33+
"mrbeam_ledstrips",
34+
"netconnectd",
35+
]
36+
for logrotate in logrotates:
37+
self._logger.debug("enable logrotate of " + logrotate)
38+
src = os.path.join(
39+
__package_path__, self.MIGRATE_LOGROTATE_FOLDER, logrotate
40+
)
41+
dst = os.path.join("/etc/logrotate.d/" + logrotate)
42+
self.exec_cmd("sudo cp {src} {dst}".format(src=src, dst=dst))
43+
44+
self._logger.debug(
45+
"restarting logrotate in order for the changed config to take effect"
46+
)
47+
48+
# needs to be optional for legacy image, as this is returning 1 instead of 0
49+
self.exec_cmd("sudo logrotate /etc/logrotate.conf", optional=True)
50+
super(Mig003EnableLogrotateBuster, self)._run()
51+
52+
def _rollback(self):
53+
# no rollback needed
54+
super(Mig003EnableLogrotateBuster, self)._rollback()

octoprint_mrbeam/migration/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
# this is for internal use
2424
from octoprint_mrbeam.migration.Mig001 import Mig001NetconnectdDisableLogDebugLevel
2525
from octoprint_mrbeam.migration.Mig002 import Mig002EnableOnlineCheck
26+
from octoprint_mrbeam.migration.Mig003 import Mig003EnableLogrotateBuster
2627

2728
# To add migrations they have to be added to this list till we automate it
2829
list_of_migrations = [
2930
Mig001NetconnectdDisableLogDebugLevel,
3031
Mig002EnableOnlineCheck,
32+
Mig003EnableLogrotateBuster,
3133
]

octoprint_mrbeam/migration/migration_base.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def state(self):
201201
"""
202202
return self._state
203203

204-
def exec_cmd(self, command):
204+
def exec_cmd(self, command, optional=False):
205205
"""
206206
wrapper of exec_cmd to change to errorstate in case of a error
207207
Args:
@@ -210,10 +210,19 @@ def exec_cmd(self, command):
210210
Returns:
211211
None
212212
Raises:
213-
MigrationException: if the execution of the command ended with a errorcode different to 0
213+
MigrationException: if the execution of the command was not successful
214214
"""
215-
if not exec_cmd(command):
216-
raise MigrationException("error during migration for cmd:", command)
215+
command_success = exec_cmd(command)
216+
if command_success:
217+
return
218+
if optional and not command_success:
219+
self._logger.warn("optional command failed - cmd: {}".format(command))
220+
else:
221+
raise MigrationException(
222+
"error during migration for cmd: {} - return: {}".format(
223+
command, command_success
224+
)
225+
)
217226

218227
@staticmethod
219228
def execute_restart(restart):

0 commit comments

Comments
 (0)