Skip to content

Commit ebd899c

Browse files
committed
Fix apt update not being run before installing apt packages dependencies
1 parent f552074 commit ebd899c

File tree

8 files changed

+22
-19
lines changed

8 files changed

+22
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ sudo service mycodoflask restart
3131

3232
- Fix inability to set the same output for PID raise and lower ([#1369](https://github.com/kizniche/Mycodo/issues/1369))
3333
- Fix OpenWeather One Call API endpoint to use v3.0 ([#1429](https://github.com/kizniche/Mycodo/pull/1429))
34+
- Fix apt update not being run before installing apt packages dependencies
3435

3536
### Features
3637

@@ -3720,7 +3721,7 @@ If you rely on your system to work, it is highly recommended that you ***DO NOT
37203721

37213722
#### Failure during the upgrade to >= 5.5.0
37223723

3723-
I found that occasionally the upgrade will spontaneously stop without an indication of the issue. I've seen it happen during an apt-get install and during a pip upgrade. It does not seem consistent, and there were no erorrs, therefore it wasn't able to be fixed. If you experience an error during the upgrade that doesn't allow the upgrade to complete, issue the following commands to attempt to resume and complete the upgrade. If that doesn't fix it, you may have to install Mycodo from scratch.
3724+
I found that occasionally the upgrade will spontaneously stop without an indication of the issue. I've seen it happen during an apt install and during a pip upgrade. It does not seem consistent, and there were no erorrs, therefore it wasn't able to be fixed. If you experience an error during the upgrade that doesn't allow the upgrade to complete, issue the following commands to attempt to resume and complete the upgrade. If that doesn't fix it, you may have to install Mycodo from scratch.
37243725

37253726
```bash
37263727
sudo dpkg --configure -a

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Open a terminal in Raspbian and run the following commands.
101101
#### Retrieve and extract the latest Mycodo release
102102

103103
```shell script
104-
sudo apt-get install git
104+
sudo apt install git
105105
git clone https://github.com/kizniche/Mycodo
106106
```
107107

mycodo/mycodo_flask/api/dependency.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
# coding=utf-8
2-
import flask_login
32
import logging
43
import threading
54
import traceback
5+
6+
import flask_login
67
from flask_accept import accept
78
from flask_restx import Resource
89
from flask_restx import abort
9-
from flask_restx import fields
10-
11-
from mycodo.databases.models import DeviceMeasurements
12-
from mycodo.databases.models import Input
13-
from mycodo.databases.models import InputChannel
14-
from mycodo.databases.models.input import InputChannelSchema
15-
from mycodo.databases.models.input import InputSchema
16-
from mycodo.databases.models.measurement import DeviceMeasurementsSchema
17-
from mycodo.mycodo_client import DaemonControl
10+
1811
from mycodo.mycodo_flask.api import api
1912
from mycodo.mycodo_flask.api import default_responses
20-
from mycodo.mycodo_flask.api.utils import get_from_db
21-
from mycodo.mycodo_flask.api.utils import return_list_of_dictionaries
2213
from mycodo.mycodo_flask.routes_admin import install_dependencies
2314
from mycodo.mycodo_flask.utils import utils_general
2415
from mycodo.mycodo_flask.utils.utils_general import return_dependencies

mycodo/mycodo_flask/routes_admin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,24 @@ def get_all_file_paths(directory):
171171
def install_dependencies(dependencies):
172172
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
173173
dependency_list = []
174+
apt_update = False
175+
174176
for each_dependency in dependencies:
177+
if each_dependency[2] == 'apt':
178+
apt_update = True
179+
175180
if each_dependency[0] not in dependency_list:
176181
dependency_list.append(each_dependency[0])
182+
177183
with open(DEPENDENCY_LOG_FILE, 'a+') as f:
178184
f.write("\n[{time}] Dependency installation beginning. Installing: {deps}\n\n".format(
179185
time=now, deps=", ".join(dependency_list)))
180186

187+
# Update apt repositories before installing apt dependencies
188+
if apt_update:
189+
cmd = f"/bin/bash {INSTALL_DIRECTORY}/mycodo/scripts/upgrade_commands.sh update-apt | ts '[%Y-%m-%d %H:%M:%S]' >> {DEPENDENCY_LOG_FILE} 2>&1"
190+
cmd_output(cmd, stdout_pipe=False, user='root')
191+
181192
for each_dep in dependencies:
182193
if each_dep[2] == 'bash-commands':
183194
for each_command in each_dep[1]:

mycodo/mycodo_flask/utils/utils_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ def settings_diagnostic_recreate_influxdb_db_2():
19451945
p = subprocess.Popen(command, shell=True)
19461946
p.communicate()
19471947
except Exception:
1948-
logger.exception()
1948+
logger.exception("recreating influxdb2x database")
19491949

19501950
flash_success_errors(
19511951
error, action, url_for('routes_settings.settings_diagnostic'))

mycodo/scripts/dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ printf "\n#### Installing/updating %s (%s)\n" "${2}" "${1}"
1818

1919
case "${1}" in
2020
'apt')
21-
apt-get install -y "${2}"
21+
apt install -y "${2}"
2222
;;
2323
'pip-pypi')
2424
if [ ! -e "${INSTALL_DIRECTORY}"/env/bin/python3 ]; then

mycodo/scripts/raspi-monitor.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# Script to enable and disable the HDMI signal of the Raspberry PI
1212
# Inspiration: http://www.raspberrypi.org/forums/viewtopic.php?t=16472&p=176258
1313
#
14-
# sudo apt-get update
15-
# sudo apt-get install git gcc libusb-dev
14+
# sudo apt update
15+
# sudo apt install git gcc libusb-dev
1616
# git clone https://github.com/codazoda/hub-ctrl.c
1717
# gcc -o hub-ctrl ./hub-ctrl.c/hub-ctrl.c -lusb
1818
# sudo cp hub-ctrl /usr/local/sbin/

mycodo/utils/update_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def get_installed_apt_dependencies():
154154
apt_deps = " ".join(installed_apt_deps)
155155

156156
if apt_deps:
157-
update_cmd = f'apt-get install -y {apt_deps}'
157+
update_cmd = f'apt install -y {apt_deps}'
158158
output, err, stat = cmd_output(update_cmd, user='root')
159159
formatted_output = output.decode("utf-8").replace('\\n', '\n')
160160
logger.info(formatted_output)

0 commit comments

Comments
 (0)