Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
586e3fc61c
6 changed files with 46 additions and 103 deletions
|
|
@ -1,81 +0,0 @@
|
|||
#!/bin/env python3
|
||||
#
|
||||
## Convert saved WiFi connections for NetworkManager
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
KNOWN_NETWORKS = '/root/known_networks'
|
||||
TEMPLATE = '''[connection]
|
||||
id={ssid}
|
||||
uuid={uuid}
|
||||
type=wifi
|
||||
permissions=user:{user}:;
|
||||
|
||||
[wifi]
|
||||
mac-address-blacklist=
|
||||
mode=infrastructure
|
||||
ssid={ssid}
|
||||
|
||||
[wifi-security]
|
||||
auth-alg=open
|
||||
key-mgmt=wpa-psk
|
||||
psk={password}
|
||||
|
||||
[ipv4]
|
||||
dns-search=
|
||||
method=auto
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=stable-privacy
|
||||
dns-search=
|
||||
method=auto
|
||||
'''
|
||||
|
||||
def get_user_name():
|
||||
"""Get user name, returns str."""
|
||||
user = None
|
||||
|
||||
# Get running user
|
||||
if 'SUDO_USER' in os.environ:
|
||||
user = os.environ.get('SUDO_USER')
|
||||
else:
|
||||
user = os.environ.get('USER')
|
||||
|
||||
# Check if user manually specified
|
||||
for a in sys.argv:
|
||||
a = a.strip().lower()
|
||||
if a.startswith('--user='):
|
||||
user = a.replace('--user=', '')
|
||||
|
||||
return user
|
||||
|
||||
if __name__ == '__main__':
|
||||
known_networks = {}
|
||||
#try:
|
||||
with open('/root/known_networks', 'r') as f:
|
||||
for line in f.readlines():
|
||||
r = re.search(r"^'(.*)':\s+'(.*)'", line.strip())
|
||||
if r:
|
||||
known_networks[r.group(1)] = r.group(2)
|
||||
for ssid, password in known_networks.items():
|
||||
out_path = '{}/{}.nmconnection'.format(
|
||||
'/etc/NetworkManager/system-connections',
|
||||
ssid,
|
||||
)
|
||||
if not os.path.exists(out_path):
|
||||
with open(out_path, 'w') as f:
|
||||
f.write(TEMPLATE.format(
|
||||
user=get_user_name(),
|
||||
ssid=ssid,
|
||||
password=password,
|
||||
uuid=uuid.uuid4(),
|
||||
))
|
||||
os.chmod(out_path, 0o600)
|
||||
#except:
|
||||
# # Meh
|
||||
# pass
|
||||
|
||||
# vim: sts=2 sw=2 ts=2
|
||||
|
|
@ -45,6 +45,10 @@ KNOWN_DISK_MODELS = {
|
|||
r'CT(250|500|1000|2000)MX500SSD(1|4)': {
|
||||
197: {'Warning': 1, 'Error': 2, 'Note': '(MX500 thresholds)',},
|
||||
},
|
||||
r'MZ(7|N)LN(128|256|512|1T0)HA(HQ|JQ|LR)-000H(1|7)': {
|
||||
# Source: https://www.smartmontools.org/ticket/920
|
||||
201: {'Error': 99, 'PercentageLife': True, 'Note': '(PM871b thresholds)'},
|
||||
},
|
||||
}
|
||||
KNOWN_RAM_VENDOR_IDS = {
|
||||
# https://github.com/hewigovens/hewigovens.github.com/wiki/Memory-vendor-code
|
||||
|
|
|
|||
|
|
@ -223,7 +223,10 @@ class Disk(BaseObj):
|
|||
continue
|
||||
|
||||
# Check attribute
|
||||
if err_thresh <= value['raw'] < max_thresh:
|
||||
if known_attributes[attr].get('PercentageLife', False):
|
||||
if 0 <= value['raw'] <= err_thresh:
|
||||
attributes_ok = False
|
||||
elif err_thresh <= value['raw'] < max_thresh:
|
||||
attributes_ok = False
|
||||
|
||||
# Done
|
||||
|
|
@ -272,14 +275,23 @@ class Disk(BaseObj):
|
|||
label = f' {label.replace("_", " "):38}'
|
||||
|
||||
# Value color
|
||||
for threshold, color in ATTRIBUTE_COLORS:
|
||||
threshold_val = known_attributes[attr].get(threshold, None)
|
||||
if threshold_val and value['raw'] >= threshold_val:
|
||||
value_color = color
|
||||
if threshold == 'Error':
|
||||
note = '(failed)'
|
||||
elif threshold == 'Maximum':
|
||||
note = '(invalid?)'
|
||||
if known_attributes[attr].get('PercentageLife', False):
|
||||
# PercentageLife values
|
||||
if 0 <= value['raw'] <= known_attributes[attr]['Error']:
|
||||
value_color = 'RED'
|
||||
note = '(failed, % life remaining)'
|
||||
elif value['raw'] < 0 or value['raw'] > 100:
|
||||
value_color = 'PURPLE'
|
||||
note = '(invalid?)'
|
||||
else:
|
||||
for threshold, color in ATTRIBUTE_COLORS:
|
||||
threshold_val = known_attributes[attr].get(threshold, None)
|
||||
if threshold_val and value['raw'] >= threshold_val:
|
||||
value_color = color
|
||||
if threshold == 'Error':
|
||||
note = '(failed)'
|
||||
elif threshold == 'Maximum':
|
||||
note = '(invalid?)'
|
||||
|
||||
# 199/C7 warning
|
||||
if str(attr) == '199' and value['raw'] > 0:
|
||||
|
|
|
|||
|
|
@ -150,12 +150,6 @@ function update_live_env() {
|
|||
mv "$TEMP_DIR/memtest86/help"/* "$PROFILE_DIR/EFI/memtest86"/
|
||||
mv "$TEMP_DIR/memtest86/license.rtf" "$PROFILE_DIR/EFI/memtest86"/
|
||||
|
||||
# build.sh
|
||||
#if ! grep -iq 'wizardkit additions' "$PROFILE_DIR/build.sh"; then
|
||||
# sed -i -r 's/^(run_once make_iso)$/# wizardkit additions\n\1/' "$PROFILE_DIR/build.sh"
|
||||
# sed -i "/# wizardkit additions/r $ROOT_DIR/setup/linux/build_additions.txt" "$PROFILE_DIR/build.sh"
|
||||
#fi
|
||||
|
||||
# Hostname
|
||||
echo "$hostname" > "$PROFILE_DIR/airootfs/etc/hostname"
|
||||
echo "127.0.1.1 $hostname.localdomain $hostname" >> "$PROFILE_DIR/airootfs/etc/hosts"
|
||||
|
|
@ -227,9 +221,23 @@ function update_live_env() {
|
|||
fi
|
||||
|
||||
# WiFi
|
||||
# TODO
|
||||
#cp "$ROOT_DIR/setup/linux/known_networks" "$PROFILE_DIR/airootfs/root/known_networks"
|
||||
#echo "add-known-networks --user=$username" >> "$PROFILE_DIR/airootfs/root/customize_airootfs.sh"
|
||||
IFS_BAK="${IFS}"
|
||||
IFS=$'\n'
|
||||
mkdir -p "$PROFILE_DIR/airootfs/var/lib/iwd"
|
||||
for line in $(<"$ROOT_DIR/setup/linux/known_networks"); do
|
||||
if [[ "${line:0:1}" == "#" ]]; then
|
||||
# Skip comments
|
||||
continue
|
||||
fi
|
||||
w_name="${line%%:::*}"
|
||||
w_pass="${line##*:::}"
|
||||
w_pass="$(wpa_passphrase "${w_name}" "${w_pass}" \
|
||||
| grep -E 'psk=[0-9a-z]+' \
|
||||
| sed -r 's/\s+psk=//')"
|
||||
echo "[Security]" > "$PROFILE_DIR/airootfs/var/lib/iwd/${w_name}.psk"
|
||||
echo "PreSharedKey=${w_pass}" >> "$PROFILE_DIR/airootfs/var/lib/iwd/${w_name}.psk"
|
||||
done
|
||||
IFS="${IFS_BAK}"
|
||||
}
|
||||
|
||||
function update_repo() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#Put WiFi network info here
|
||||
#'WiFi SSID': 'WiFi Password'
|
||||
'1201computersXI': 'wifipassword'
|
||||
'1201computersXI-5g': 'wifipassword'
|
||||
# Put known WiFi networks in the form:
|
||||
1201computersXI:::wifipassword
|
||||
1201computersXI-5g:::wifipassword
|
||||
|
|
|
|||
|
|
@ -31,3 +31,4 @@ startup-notification
|
|||
subversion
|
||||
syslinux
|
||||
tigervnc
|
||||
wpa_supplicant
|
||||
|
|
|
|||
Loading…
Reference in a new issue