This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/Fix.sh

66 lines
1.9 KiB
Bash

# Fix when ethernet mistakenly detects 100 Mb instead of 1000 Mb.
# SPEED is one of 10/100/1000 etc.
# Usage: fix_ethernet_speed <DEVICE> <SPEED>
function fix_ethernet_speed() {
local device="${1}"
local speed="${2}"
if [[ "${device}" = "" || "${speed}" = "" ]]; then
help fix_ethernet_speed
return 2
fi
ethtool -s "${device}" speed "${speed}"
}
# Fix nautilus after typing wrong sftp password.
function fix_files_sftp() {
secret-tool clear protocol sftp
}
# Delete lost Gradle lock files.
function fix_gradle_lock() {
cd "${HOME}/.gradle" && find -type f | grep \\.lock$ | xargs -- rm
}
# Fix Gnome's broken RDP ffs.
# Usage: fix_gnome_rdp <USER> <PASSWORD>
function fix_gnome_rdp() {
local user="${1}"
local password="${2}"
# Check params.
if [[ "${user}" = "" ]] || [[ "${password}" = "" ]]; then
help fix_gnome_rdp
return 2
fi
# Unlock keyring. PROTIP: Disable password for it in password manager.
pkill -9 -f gnome-keyring-daemon
echo -n "${user}" | gnome-keyring-daemon --unlock
# Generate keys.
cd /tmp
openssl genrsa -out rdp-tls.key 4096
openssl req -new -key rdp-tls.key -subj "/C=US" | openssl x509 -req -days 730 -signkey rdp-tls.key -out rdp-tls.crt
mkdir -p /home/"${user}"/.local/share/gnome-remote-desktop/
mv rdp-tls.key rdp-tls.crt /home/"${user}"/.local/share/gnome-remote-desktop/
# Configure RDP.
grdctl rdp set-tls-cert /home/"${user}"/.local/share/gnome-remote-desktop/rdp-tls.crt
grdctl rdp set-tls-key /home/"${user}"/.local/share/gnome-remote-desktop/rdp-tls.key
grdctl rdp set-credentials "${user}" "${password}"
grdctl rdp disable-view-only
# Start service.
grdctl rdp enable
systemctl --user start gnome-remote-desktop.service
# Show status.
grdctl status --show-credentials
systemctl --user status gnome-remote-desktop.service
# Show extra info.
_warn "You may need to manually restart Desktop sharing via Gnome Settings."
}