Python pipx!

This commit is contained in:
vidplace7 2025-04-25 18:15:06 -04:00
parent 6f16acfae1
commit cee669dcaf
6 changed files with 18 additions and 132 deletions

View file

@ -1,13 +1,6 @@
echo "Inside chroot environment..."
echo "tmpfs /run tmpfs rw,nodev,nosuid,size=32M 0 0" | tee -a /etc/fstab
# Temporarily removed for SEGFAULT fix done after upgrade below.
#echo "Installing Meshtastic..."
#wget -qO- https://meshtastic.github.io/meshtastic-deb.asc | tee /etc/apt/keyrings/meshtastic-deb.asc >/dev/null
#if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi
#echo "deb [arch=all signed-by=/etc/apt/keyrings/meshtastic-deb.asc] https://meshtastic.github.io/deb stable main" | tee /etc/apt/sources.list.d/meshtastic-deb.list >/dev/null
echo "Removing netdevice rules..."
ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
@ -23,7 +16,10 @@ ln -sf /usr/share/zoneinfo/UTC /etc/localtime
echo "Installing packages..."
apt update
DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" linux-firmware wireless-tools git python3.10-venv libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev evtest screen avahi-daemon protobuf-compiler telnet fonts-noto-color-emoji ninja-build chrony qrencode software-properties-common python-is-python3 python3.10-venv lsof spi-tools python3-luma.oled samba vim mtd-utils jq rsync
DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" \
linux-firmware wireless-tools git evtest screen telnet software-properties-common lsof ninja-build chrony samba vim mtd-utils jq rsync \
avahi-daemon protobuf-compiler qrencode spi-tools fonts-noto-color-emoji \
python3-luma.oled python-is-python3 python3.10-venv pipx
if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi
DEBIAN_FRONTEND=noninteractive apt upgrade -y --option Dpkg::Options::="--force-confold"
@ -37,9 +33,15 @@ DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-
#DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" ./meshtasticd_2.5.11.8e2a3e5_armhf.deb
#rm ./meshtasticd_2.5.11.8e2a3e5_armhf.deb
echo "Installing dependencies for meshing-around and meshtastic cli..."
echo "Add pipx global dir to the PATH"
pipx ensurepath --global
echo "Installing dependencies for meshing-around..."
#pip config set global.extra-index-url https://www.piwheels.org/simple
pip3 install requests pyephem pytap2 meshtastic pypubsub geopy maidenhead beautifulsoup4 dadjokes schedule wikipedia googlesearch-python pubsub datetime
pip3 install requests pyephem pytap2 pypubsub geopy maidenhead beautifulsoup4 dadjokes schedule wikipedia googlesearch-python pubsub datetime
echo "Install meshtastic cli in pipx-managed venv"
pipx install --global "meshtastic[cli]"
if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi
@ -48,12 +50,6 @@ wget -qO- https://api.github.com/repos/tsl0922/ttyd/releases/latest | grep "brow
chmod +x /opt/ttyd/ttyd
systemctl enable ttyd
echo "Cloning Control for Meshtastic by pdxlocations"
git clone https://github.com/pdxlocations/control.git /opt/control
pip install -r /opt/control/requirements.txt
chown -R femto /opt/control
git config --global --add safe.directory /opt/control # prevents git error when updating
echo "Setting MOTD..."
mv /etc/update-motd.d/10-help-text /etc/update-motd.d/10-help-text.bak
mv /etc/update-motd.d/60-unminimize /etc/update-motd.d/60-unminimize.bak

View file

@ -12,12 +12,10 @@
name="Contact" # software name
author="pdxlocations" # software author - OPTIONAL
description="A Text-Based Console UI for Meshtastic Nodes. Formerly called Curses Client.\nAfter install, run \`contact\` to launch." # software description - OPTIONAL (but strongly recommended!)
URL="https://github.com/pdxlocations/contact/" # software URL. Can contain multiple URLs - OPTIONAL
URL="https://pypi.org/project/contact/" # software URL. Can contain multiple URLs - OPTIONAL
options="xiuglNADUOLGTCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
launch="echo \"Stopping conflicting services (if any), will restart after exit...\" && sudo femto-utils.sh -A stop && sudo -u ${SUDO_USER:-$(whoami)} env LANG=$LANG TERM=$TERM NCURSES_NO_UTF8_ACS=$NCURSES_NO_UTF8_ACS python /opt/contact/main.py --host && echo \"Restarting conflicting services (if any)...\" && sudo femto-utils.sh -A start" # command to launch software, if applicable
service_name="" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
location="/opt/contact" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
license="$location/LICENSE" # file to cat to display license
license_name="GPL3" # license name, such as MIT, GPL3, custom, whatever. short text string.
conflicts="\"Full control\" Meshtastic software, such as TC²-BBS and Meshing Around - but only while running." # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
@ -31,61 +29,27 @@ fi
# install script
install() {
if ! git clone https://github.com/pdxlocations/contact.git /opt/contact; then
echo "user_message: Git clone failed. Is internet connected?"
exit 1
fi
pip install -r $location/requirements.txt
chown -R femto $location #give ownership of installation directory to $user
git config --global --add safe.directory $location # prevents git error when updating
echo "Creating \`contact\` shortcut."
echo -e "#!/bin/bash\n\
export NCURSES_NO_UTF8_ACS=1\n\
export TERM=xterm-256color\n\
export LANG=C.UTF-8\n\
$launch" | sudo tee /usr/local/bin/contact > /dev/null
chmod +x /usr/local/bin/contact
echo "user_message: To launch, run \`contact\`."
exit 0 # should be `exit 1` if the installation failed
pipx install --global contact
}
# uninstall script
uninstall() {
rm -rf $location
echo "Removed \`$location\`."
rm /usr/local/bin/contact
echo "Removed \`contact\` shortcut."
echo "user_message: All files removed."
exit 0 # should be `exit 1` if the installation failed
pipx uninstall --global contact
}
#upgrade script
upgrade() {
cd $location
if ! git pull; then
echo "user_message: Git pull failed. Is internet connected?"
exit 1
fi
exit 0
pipx upgrade --global contact
}
# Check if already installed. `exit 0` if yes, `exit 1` if no
check() {
#the following works for cloned repos, but not for apt installs
if [ -d "$location" ]; then
#echo "Already installed"
exit 0
else
#echo "Not installed"
exit 1
fi
pipx list --global --short | grep contact
}
# display license
license() {
echo -e "Contents of $license:\n\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
echo "GNU General Public License v3.0"
}
# parse arguments

View file

@ -1,74 +0,0 @@
#!/bin/bash
### For package maintainer:
# Fill the following fields and choose the options that are in use by this package
# Populate the install, uninstall and upgrade functions
# Remember that this script may be launched in terminal, via web UI or another method, so inputs aren't always possible
# This system supports both interactive and non-interactive installs. For non-interactive installs, $interaction="false". In this cause special instructions to the user should be given as user_message, such as `After installation, edit /opt/software/config.ini`
# Successful operations should `exit 0`, fails should `exit 1`
# Messages to the user (such as configuration instructions, explanatory error messages, etc) should be given as: `echo "user_message: text"`
# Everything following `user_message: ` will be displayed prominently to the user, so it must the last thing echoed
name="Control for Meshtastic" # software name
author="pdxlocations" # software author - OPTIONAL
description="Control for Meshtastic is a fully-featured Meshtastic configuration tool made for running in console, utilizing Curses.\n\nControl is installed by default on Femtofox and is used for Meshtastic configuration in femto-config. Uninstallation is not recommended." # software description - OPTIONAL (but strongly recommended!)
URL="https://github.com/pdxlocations/control" # software URL. Can contain multiple URLs - OPTIONAL
options="hxiuglNADUOLGTIC" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
launch="echo \"Stopping conflicting services (if any), will restart after exit...\" && sudo femto-utils.sh -A stop && sudo -u ${SUDO_USER:-$(whoami)} env LANG=$LANG TERM=$TERM NCURSES_NO_UTF8_ACS=$NCURSES_NO_UTF8_ACS python /opt/control/main.py --host && echo \"Restarting conflicting services (if any)...\" && sudo femto-utils.sh -A start" # command to launch software, if applicable
license="/opt/control/LICENSE" # file to cat to display license
location="/opt/control" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
license="$location/LICENSE" # file to cat to display license
license_name="GPL3" # license name, such as MIT, GPL3, custom, whatever. short text string
conflicts="\"Full control\" Meshtastic software, such as TC²-BBS and Meshing Around - but only while running." # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
# install script
install() {
if ! git clone https://github.com/pdxlocations/control.git /opt/control; then
echo "user_message: Git clone failed. Is internet connected?"
exit 1
fi
pip install -r $location/requirements.txt
chown -R femto $location #give ownership of installation directory to $user
git config --global --add safe.directory $location # prevents git error when updating
echo "user_message: To launch, go to Meshtastic settings. Launching manually may conflict with \`full control\` Meshtastic software such as BBS."
exit 0 # should be `exit 1` if operation failed
}
# uninstall script
uninstall() {
rm -rf $location
echo "Removed \`$location\`."
echo "user_message: All files removed."
exit 0 # should be `exit 1` if operation failed
}
#upgrade script
upgrade() {
cd $location
if ! git pull; then
echo "user_message: Git pull failed. Is internet connected?"
exit 1
fi
exit 0
}
# Check if already installed. `exit 0` if yes, `exit 1` if no
check() {
#the following works for cloned repos, but not for apt installs
if [ -d "$location" ]; then
#echo "Already installed"
exit 0
else
#echo "Not installed"
exit 1
fi
}
# display license
license() {
echo -e "Contents of $license:\n\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
}
# parse arguments
source /usr/local/bin/packages/femto_argument_parse.sh "$@"
exit 0