mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-05 03:21:40 +00:00
Add the following args to the install script: Syntax: sudo ./install.sh [-h|m|n|q] options: -h Display this help message. -m Install and configure NetworkManager (Ubuntu only). -n Disable networking. This will also prevent installation of NetworkManager. -q Silent install, automatically accepts all defaults. For non-interactive use.
This commit is contained in:
@@ -43,6 +43,7 @@ public class NetworkManager {
|
|||||||
public void initialize(boolean shouldManage) {
|
public void initialize(boolean shouldManage) {
|
||||||
isManaged = shouldManage && !networkingIsDisabled;
|
isManaged = shouldManage && !networkingIsDisabled;
|
||||||
if (!isManaged) {
|
if (!isManaged) {
|
||||||
|
logger.info("Network management is disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,42 @@ package_is_installed(){
|
|||||||
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -q "ok installed"
|
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -q "ok installed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
help() {
|
||||||
|
echo "This script installs Photonvision."
|
||||||
|
echo "It must be run as root."
|
||||||
|
echo
|
||||||
|
echo "Syntax: sudo ./install.sh [-h|m|n|q]"
|
||||||
|
echo " options:"
|
||||||
|
echo " -h Display this help message."
|
||||||
|
echo " -m Install and configure NetworkManager (Ubuntu only)."
|
||||||
|
echo " -n Disable networking. This will also prevent installation of NetworkManager."
|
||||||
|
echo " -q Silent install, automatically accepts all defaults. For non-interactive use."
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTALL_NETWORK_MANAGER="false"
|
||||||
|
|
||||||
|
while getopts ":hmnq" name; do
|
||||||
|
case "$name" in
|
||||||
|
h)
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
m) INSTALL_NETWORK_MANAGER="true"
|
||||||
|
;;
|
||||||
|
n) DISABLE_NETWORKING="true"
|
||||||
|
;;
|
||||||
|
q) QUIET="true"
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Error: Invalid option -- '$OPTARG'"
|
||||||
|
echo "Try './install.sh -h' for more information."
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $(($OPTIND -1))
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
echo "This script must be run as root" 1>&2
|
echo "This script must be run as root" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -34,6 +70,16 @@ fi
|
|||||||
echo "This is the installation script for PhotonVision."
|
echo "This is the installation script for PhotonVision."
|
||||||
echo "Installing for platform $ARCH_NAME"
|
echo "Installing for platform $ARCH_NAME"
|
||||||
|
|
||||||
|
DISTRO=$(lsb_release -is)
|
||||||
|
if [[ "$DISTRO" = "Ubuntu" && "$INSTALL_NETWORK_MANAGER" != "true" && -z "$QUIET" && -z "$DISABLE_NETWORKING" ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "Photonvision uses NetworkManager to control networking on your device."
|
||||||
|
read -p "Do you want this script to install and configure NetworkManager? [y/N]: " response
|
||||||
|
if [[ $response == [yY] || $response == [yY][eE][sS] ]]; then
|
||||||
|
INSTALL_NETWORK_MANAGER="true"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Installing curl..."
|
echo "Installing curl..."
|
||||||
apt-get install --yes curl
|
apt-get install --yes curl
|
||||||
echo "curl installation complete."
|
echo "curl installation complete."
|
||||||
@@ -53,6 +99,16 @@ else
|
|||||||
echo 'GOVERNOR=performance' > /etc/default/cpufrequtils
|
echo 'GOVERNOR=performance' > /etc/default/cpufrequtils
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$INSTALL_NETWORK_MANAGER" == "true" ]]; then
|
||||||
|
echo "Installing network-manager..."
|
||||||
|
apt-get install --yes network-manager
|
||||||
|
cat > /etc/netplan/00-default-nm-renderer.yaml <<EOF
|
||||||
|
network:
|
||||||
|
renderer: NetworkManager
|
||||||
|
EOF
|
||||||
|
echo "network-manager installation complete."
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Installing the JRE..."
|
echo "Installing the JRE..."
|
||||||
if ! package_is_installed openjdk-17-jre-headless
|
if ! package_is_installed openjdk-17-jre-headless
|
||||||
then
|
then
|
||||||
@@ -85,7 +141,10 @@ echo "Downloaded latest stable release of PhotonVision."
|
|||||||
|
|
||||||
echo "Creating the PhotonVision systemd service..."
|
echo "Creating the PhotonVision systemd service..."
|
||||||
|
|
||||||
|
# service --status-all doesn't list photonvision on OrangePi use systemctl instead:
|
||||||
|
#if systemctl --quiet is-active photonvision; then
|
||||||
if service --status-all | grep -Fq 'photonvision'; then
|
if service --status-all | grep -Fq 'photonvision'; then
|
||||||
|
echo "PhotonVision is already running. Stopping service."
|
||||||
systemctl stop photonvision
|
systemctl stop photonvision
|
||||||
systemctl disable photonvision
|
systemctl disable photonvision
|
||||||
rm /lib/systemd/system/photonvision.service
|
rm /lib/systemd/system/photonvision.service
|
||||||
@@ -116,6 +175,10 @@ RestartSec=1
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
if [ "$DISABLE_NETWORKING" = "true" ]; then
|
||||||
|
sed -i "s/photonvision.jar/photonvision.jar -n/" /lib/systemd/system/photonvision.service
|
||||||
|
fi
|
||||||
|
|
||||||
cp /lib/systemd/system/photonvision.service /etc/systemd/system/photonvision.service
|
cp /lib/systemd/system/photonvision.service /etc/systemd/system/photonvision.service
|
||||||
chmod 644 /etc/systemd/system/photonvision.service
|
chmod 644 /etc/systemd/system/photonvision.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|||||||
Reference in New Issue
Block a user