mirror of
https://github.com/femtofox/femtofox.git
synced 2026-11-20 15:06:36 -05:00
Merge pull request #178 from noon92/software_menu
Refactoring of software menu - now a package manager!
This commit is contained in:
commit
4597df0c77
7 changed files with 900 additions and 166 deletions
|
|
@ -501,7 +501,7 @@ while true; do
|
|||
1 "Settings wizard" \
|
||||
2 "Networking" \
|
||||
3 "Meshtasticd" \
|
||||
4 "Software" \
|
||||
4 "Software manager" \
|
||||
5 "Utilities" \
|
||||
6 "Help" \
|
||||
"" "" \
|
||||
|
|
|
|||
|
|
@ -1,186 +1,132 @@
|
|||
#!/bin/bash
|
||||
export NCURSES_NO_UTF8_ACS=1
|
||||
export TERM=screen
|
||||
export LANG=C.UTF-8
|
||||
|
||||
uninstall="false"
|
||||
title="Software Manager"
|
||||
package_dir="/usr/local/bin/packages"
|
||||
|
||||
meshing_around() { # Install Meshing Around
|
||||
failedInstall=false
|
||||
#check if /opt/meshing-around exists if not git clone
|
||||
if [ ! -d /opt/meshing-around ]; then
|
||||
dialog --title "$software" --yesno "Meshing Around is a feature-rich bot designed to enhance your Meshtastic network experience with a variety of powerful tools and fun features\nConnectivity and utility through text-based message delivery.\nWhether you're looking to perform network tests, send messages, or even play games, mesh_bot.py has you covered.\nInstallation requires internet connection.\n\nLearn more at https://github.com/SpudGunMan/meshing-around\nIf software is already present, will attempt to update.\n\nInstall?" 0 0
|
||||
if [ $? -eq 0 ]; then #unless cancel/no
|
||||
if ! git clone https://github.com/spudgunman/meshing-around /opt/meshing-around; then
|
||||
dialog --title "$software" --msgbox "\nCloning of Meshing Around git repo failed.\nCheck internet connectivity." 10 60
|
||||
failedInstall=true
|
||||
fi
|
||||
fi
|
||||
install() {
|
||||
dialog --title "$title" --yesno "\nInstall $($package_dir/$1.sh -N)\n\nProceed?" 10 40
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
echo "Installing $($package_dir/$1.sh -N)..."
|
||||
# Run the installation script, capturing the output and displaying it in real time
|
||||
output=$(eval "$package_dir/$1.sh -i 2>&1 | tee /dev/tty")
|
||||
install_status=$? # Capture the exit status of the eval command
|
||||
user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present
|
||||
output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output
|
||||
|
||||
if [ $install_status -eq 0 ]; then # if the installation was successful
|
||||
dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
else
|
||||
# /opt/meshing-around exists, check for updates
|
||||
cd /opt/meshing-around
|
||||
if ! sudo git pull; then
|
||||
dialog --title "$software" --msgbox "\nFailed to update Meshing Around.\nCheck internet connectivity." 10 60
|
||||
failedInstall=true
|
||||
fi
|
||||
# check if /opt/meshing-around/data has any .pkl files if so assume it's installed
|
||||
if [ -n "$(find /opt/meshing-around/data -name '*.pkl' -print -quit)" ]; then
|
||||
# todo uninstall?
|
||||
dialog --title "$software" --yesno "Meshing Around appears installed and updated, do you want to edit the config file? (press ctl+o,enter to save, ctl+x to exit nano)" 0 0
|
||||
if [ $? -eq 0 ]; then #unless cancel/no
|
||||
sudo nano /opt/meshing-around/config.ini
|
||||
fi
|
||||
# set flag to not run install.sh
|
||||
installed=true
|
||||
echo "Restarting services..."
|
||||
sudo systemctl restart mesh_bot
|
||||
sudo systemctl restart pong_bot
|
||||
fi
|
||||
fi
|
||||
# if /opt/meshing-around exists
|
||||
if [ -f /opt/meshing-around/install.sh ] && [ "$installed" != true ] && [ "$failedInstall" != true ]; then
|
||||
# ask what type of bot mesh or pong
|
||||
dialog --title "$software" --yesno "Meshing Around can be configured to run as mesh_bot or pong_bot.\n\nRun mesh_bot?" 0 0
|
||||
if [ $? -eq 0 ]; then #unless cancel/no
|
||||
/opt/meshing-around/install.sh mesh
|
||||
dialog --title "$software" --yesno "Would you like to edit the config file? (press ctl+s save, ctl+x to exit editor)" 0 0
|
||||
if [ $? -eq 0 ]; then #unless cancel/no
|
||||
sudo nano /opt/meshing-around/config.ini
|
||||
echo "Restarting services..."
|
||||
sudo systemctl restart mesh_bot
|
||||
fi
|
||||
# finished. display the contents of install_notes.txt
|
||||
dialog --title "$software" --textbox /opt/meshing-around/install_notes.txt 20 60
|
||||
else
|
||||
/opt/meshing-around/install.sh pong
|
||||
dialog --title "$software" --yesno "Would you like to edit the config file? (press ctl+s save, ctl+x to exit editor)" 0 0
|
||||
if [ $? -eq 0 ]; then #unless cancel/no
|
||||
sudo nano /opt/meshing-around/config.ini
|
||||
echo "Restarting services..."
|
||||
sudo systemctl restart pong_bot
|
||||
fi
|
||||
# finished. display the contents of install_notes.txt
|
||||
dialog --title "$software" --textbox /opt/meshing-around/install_notes.txt 20 60
|
||||
fi
|
||||
dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
tc2_bbs() { # Install TC²BBS
|
||||
dialog --title "$software" --yesno "The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory.\nInstallation requires internet connection.\n\nLearn more at https://github.com/TheCommsChannel/TC2-BBS-mesh\nIf software is already present, will attempt to update.\n\nInstall?" 0 0
|
||||
if [ $? -eq 0 ]; then #unless cancel/no
|
||||
if [ ! -d /opt/TC2-BBS-mesh ]; then
|
||||
if ! git clone https://github.com/TheCommsChannel/TC2-BBS-mesh.git /opt/TC2-BBS-mesh; then
|
||||
dialog --title "$software" --msgbox "\nCloning of TC²-BBS git repo failed.\nCheck internet connectivity." 10 60
|
||||
return
|
||||
fi
|
||||
chown -R femto /opt/TC2-BBS-mesh
|
||||
git config --global --add safe.directory /opt/TC2-BBS-mesh # prevents git error when updating
|
||||
else
|
||||
# /opt/meshing-around exists, check for updates
|
||||
cd /opt/TC2-BBS-mesh
|
||||
if ! sudo git pull; then
|
||||
dialog --title "$software" --msgbox "\nFailed to update TC²-BBS.\nCheck internet connectivity." 10 60
|
||||
return
|
||||
fi
|
||||
fi
|
||||
uninstall() {
|
||||
dialog --title "$title" --yesno "\nUninstall $1\n\nWill permanently delete all files and settings. Proceed?" 10 40
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
echo "Uninstalling $($package_dir/$1.sh -N)..."
|
||||
output=$(eval "$package_dir/$1.sh -u 2>&1 | tee /dev/tty")
|
||||
install_status=$? # Capture the exit status of the eval command
|
||||
user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present
|
||||
output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output
|
||||
if [ $install_status -eq 0 ]; then # if the installation was successful
|
||||
dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
else
|
||||
return
|
||||
dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
fi
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
dialog --title "$title" --yesno "\nUpgrade $1\n\nProceed?" 10 40
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
if [ ! -f /opt/TC2-BBS-mesh/config.ini ]; then # if the config file doesn't exist but the clone was successful, then we need to do some configuring and rejiggering
|
||||
cd /opt/TC2-BBS-mesh
|
||||
echo "Creating virtual environment. This can take a couple minutes."
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
mv example_config.ini config.ini
|
||||
sed -i 's/type = serial/type = tcp/' config.ini
|
||||
sed -i 's/^# hostname = 192.168.x.x/hostname = 127.0.0.1/' config.ini
|
||||
fi
|
||||
echo "Installation/upgrade successful! Adding/recreating service."
|
||||
cd /opt/TC2-BBS-mesh
|
||||
source venv/bin/activate
|
||||
sed -i "s/pi/${SUDO_USER:-$(whoami)}/g" mesh-bbs.service
|
||||
sed -i "s|/home/femto/|/opt/|g" mesh-bbs.service
|
||||
cp mesh-bbs.service /etc/systemd/system/
|
||||
sudo systemctl enable mesh-bbs.service
|
||||
sudo systemctl restart mesh-bbs.service
|
||||
echo "Upgrading $($package_dir/$1.sh -N)..."
|
||||
output=$(eval "$package_dir/$1.sh -g 2>&1 | tee /dev/tty")
|
||||
install_status=$? # Capture the exit status of the eval command
|
||||
user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present
|
||||
output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output
|
||||
if [ $install_status -eq 0 ]; then # if the installation was successful
|
||||
dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
else
|
||||
dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
fi
|
||||
|
||||
# for whatever reason, this is necessary
|
||||
sleep 5
|
||||
sudo systemctl restart mesh-bbs
|
||||
|
||||
echo -e "\nPress any key to continue..."
|
||||
read -n 1 -s -r
|
||||
dialog --title "$software" --msgbox "\nInstallation complete." 8 50
|
||||
}
|
||||
|
||||
|
||||
curses_client() { # Install curses client
|
||||
git clone https://github.com/pdxlocations/curses-client-for-meshtastic.git /opt/curses-client-for-meshtastic
|
||||
ln -s /opt/curses-client-for-meshtastic/meshtastic-curses.py ~/meshtastic-curses.py
|
||||
# config the curses client to localhost tcp TODO, permissions?
|
||||
dialog --title "$software" --msgbox "\nInstallation complete.\n\nRun \`~/meshtastic-curses.py\` to launch." 10 60
|
||||
# build and display package intro
|
||||
package_intro() {
|
||||
echo "Loading package info..."
|
||||
# check if each field in the package info is supported by the package, and if so get it and insert it into the package info dialog
|
||||
dialog --colors --title "$title" --msgbox "\
|
||||
$($package_dir/$1.sh -N)\n\
|
||||
$(if $package_dir/$1.sh -O | grep -q 'A'; then echo -e "by $($package_dir/$1.sh -A)"; fi)\n\
|
||||
$(if $package_dir/$1.sh -O | grep -q 'D'; then echo "\n$($package_dir/$1.sh -D)"; fi)\n\
|
||||
\n\
|
||||
$(echo "Currently: " && $package_dir/$1.sh -I && echo "\Zuinstalled\Zn" || echo "\Zunot installed\Zn")\n\
|
||||
$(if $package_dir/$1.sh -O | grep -q 'L'; then echo "Installs to: \Zu$($package_dir/$1.sh -L)\Zn"; fi)\n\
|
||||
$(if $package_dir/$1.sh -O | grep -q 'C'; then echo "Conflicts with: \Zu$($package_dir/$1.sh -C)\Zn\n"; fi)\n\
|
||||
An internet connection is required for installation.\n\
|
||||
$(if $package_dir/$1.sh -O | grep -q 'U'; then echo "\nFor more information, visit $($package_dir/$1.sh -U)"; fi)" 0 0
|
||||
package_menu $1 # after user hits "OK", move on to package menu
|
||||
}
|
||||
|
||||
|
||||
mosquitto() { # Install mosquitto
|
||||
apt update
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" mosquitto mosquitto-clients
|
||||
# config mosquitto to listen on all interfaces and allow anonymous
|
||||
sudo sh -c "echo 'listener 1883 0.0.0.0\nallow_anonymous true' >> /etc/mosquitto/mosquitto.conf"
|
||||
sudo systemctl restart mosquitto
|
||||
dialog --title "$software" --msgbox "\nInstallation complete.\n\nMosquitto service has been started." 10 60
|
||||
package_menu() {
|
||||
while true; do
|
||||
echo "Loading package menu..."
|
||||
# for each line, check if it's supported by the package, display it if the current install state of the package is appropriate (example: don't display "install" if the package is already installed, don't display "stop service" for a package with no services)
|
||||
choice=$(dialog --title "$title" --cancel-label "Back" --menu "$($package_dir/$1.sh -N)" 16 45 5 \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'l' && $package_dir/$1.sh -I; then echo "Run software x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'i' && ! $package_dir/$1.sh -I; then echo "Install x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'u' && $package_dir/$1.sh -I; then echo "Uninstall x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'g' && $package_dir/$1.sh -I; then echo "Upgrade x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'e' && $package_dir/$1.sh -I; then echo "Enable service x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'd' && $package_dir/$1.sh -I; then echo "Disable service x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 's' && $package_dir/$1.sh -I; then echo "Stop service x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'r' && $package_dir/$1.sh -I; then echo "Start/restart service x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'S' && $package_dir/$1.sh -I; then echo "Get service status x"; fi) \
|
||||
"" "" \
|
||||
"Back to software manager" "" 3>&1 1>&2 2>&3)
|
||||
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
|
||||
if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
# execute the actual commands
|
||||
case $choice in
|
||||
"Run software") eval "$package_dir/$1.sh -l" ;;
|
||||
"Install") install $1 ;;
|
||||
"Uninstall") uninstall $1 ;;
|
||||
"Upgrade") upgrade $1 ;;
|
||||
"Enable service") eval "$package_dir/$1.sh -e" ;;
|
||||
"Disable service") eval "$package_dir/$1.sh -d" ;;
|
||||
"Stop service") eval "$package_dir/$1.sh -s" ;;
|
||||
"Start/restart service") eval "$package_dir/$1.sh -r" ;;
|
||||
"Get service status") dialog --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;;
|
||||
"Back to software manager") break ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
gpsd() { # Install gpsd
|
||||
apt update
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" gpsd gpsd-clients python-gps
|
||||
# do stuff TODO config gpsd and chrony
|
||||
# telemetry script
|
||||
sudo systemctl restart gpsd
|
||||
dialog --title "$software" --msgbox "\nInstallation complete.\n\nGPSD." 10 60
|
||||
}
|
||||
|
||||
|
||||
help=$(cat <<EOF
|
||||
If script is run without arguments, a dialog menu UI will load.
|
||||
Options are:
|
||||
-h This message
|
||||
-u Uninstall - must be FIRST argument. if this is not set, the default operation is to install the software
|
||||
-s Meshing Around by Spud
|
||||
-b The Comms Channel BBS, TC²BBS
|
||||
-c Curses Client for Meshtastic
|
||||
-m Mosquitto MQTT broker
|
||||
-g GPS and Telemetry
|
||||
EOF
|
||||
)
|
||||
# Parse options
|
||||
while getopts ":husbcmg" opt; do
|
||||
case ${opt} in
|
||||
h) echo help && exit 0 ;;
|
||||
u) uninstall="true" ;;
|
||||
s) meshing_around ;;
|
||||
b) tc2_bbs ;;
|
||||
c) curses_client ;;
|
||||
m) mosquitto ;;
|
||||
g) gpsd ;;
|
||||
esac
|
||||
done
|
||||
if [ -n "$1" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
while true; do
|
||||
title="Software"
|
||||
title="$title"
|
||||
option=""
|
||||
option=$(dialog --cancel-label "Back" --menu "$title" 0 0 6 \
|
||||
1 "Meshing Around by Spud" \
|
||||
2 "The Comms Channel BBS, TC²BBS" \
|
||||
3 "Curses Client for Meshtastic" \
|
||||
4 "Mosquitto MQTT broker" \
|
||||
5 "GPS and Telemetry" \
|
||||
"" ""\
|
||||
6 "Back to Main Menu" 3>&1 1>&2 2>&3)
|
||||
4 "Back to Main Menu" 3>&1 1>&2 2>&3)
|
||||
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
|
|
@ -188,13 +134,17 @@ title="Software"
|
|||
fi
|
||||
|
||||
case $option in
|
||||
1) meshing_around ;;
|
||||
2) tc2_bbs ;;
|
||||
3) curses_client ;;
|
||||
4) mosquitto ;;
|
||||
5) gpsd ;;
|
||||
6) break ;;
|
||||
1) package_intro "meshing_around" ;;
|
||||
2) package_intro "tc2_bbs" ;;
|
||||
3) package_intro "curses_client" ;;
|
||||
4) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
|
||||
|
||||
# 4 "Mosquitto MQTT broker" \
|
||||
# 5 "GPS and Telemetry" \
|
||||
# 4) mosquitto ;;
|
||||
# 5) gpsd ;;
|
||||
169
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh
Executable file
169
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh
Executable file
|
|
@ -0,0 +1,169 @@
|
|||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args="$@" # arguments to this script
|
||||
interactive="true"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
-h This message
|
||||
Environment - must be first argument:
|
||||
-x User UI is not terminal (script interactive unavailable)
|
||||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-l Command to run software
|
||||
Information:
|
||||
-N Get name
|
||||
-A Get author
|
||||
-D Get description
|
||||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Get Install location
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
)
|
||||
|
||||
### 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 really possible
|
||||
# Arguments to the script are stored in $args
|
||||
# This system supports both interactive and non-interactive installs. For non-interactive installs, $interactive="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="Curses Client for Meshtastic" # software name
|
||||
author="pdxlocations" # software author - OPTIONAL
|
||||
description="Command line client using the curses library, powered by Meshtastic.org.\nAfter install, run \`curses\` to launch." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://github.com/pdxlocations/curses-client-for-meshtastic/" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiuglNADUOLIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="python /opt/curses-client-for-meshtastic/main.py --host" # 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/curses-client-for-meshtastic" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="" # 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"
|
||||
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# install script
|
||||
install() {
|
||||
if ! git clone https://github.com/pdxlocations/curses-client-for-meshtastic.git /opt/curses-client-for-meshtastic; then
|
||||
echo "user_message: Git clone failed. Is internet connected?"
|
||||
exit 1
|
||||
fi
|
||||
chown -R femto $location #give ownership of installation directory to $user
|
||||
git config --global --add safe.directory $location # prevents git error when updating
|
||||
|
||||
if ! grep -Fxq "alias curses" "/home/${SUDO_USER:-$(whoami)}/.bashrc"; then
|
||||
echo "alias curses='python $location/main.py --host'" >> "/home/${SUDO_USER:-$(whoami)}/.bashrc"
|
||||
echo "Shortcut \`curses\` added to .bashrc"
|
||||
else
|
||||
echo "Shortcut already exists in .bashrc"
|
||||
fi
|
||||
source /home/${SUDO_USER:-$(whoami)}/.bashrc
|
||||
echo "user_message: To launch, run \`curses\`."
|
||||
exit 0 # should be `exit 1` if the installation failed
|
||||
}
|
||||
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
rm -rf $location
|
||||
sed -i "/alias curses/d" "/home/${SUDO_USER:-$(whoami)}/.bashrc"
|
||||
echo "Shortcut \`curses\` removed from .bashrc"
|
||||
source /home/${SUDO_USER:-$(whoami)}/.bashrc
|
||||
echo "user_message: All files removed shortcut \`curses\` removed."
|
||||
exit 0 # should be `exit 1` if the installation 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
|
||||
}
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
x) # Option -x (no user interaction available)
|
||||
interactive="false"
|
||||
;;
|
||||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
e) # Option -e (Enable service, if applicable)
|
||||
systemctl enable $service_name
|
||||
;;
|
||||
d) # Option -d (Disable service, if applicable)
|
||||
systemctl disable $service_name
|
||||
;;
|
||||
s) # Option -s (Stop service)
|
||||
systemctl stop $service_name
|
||||
;;
|
||||
r) # Option -r (Start/Restart)
|
||||
systemctl restart $service_name
|
||||
;;
|
||||
l) # Option -l (Run software)
|
||||
echo "Launching $name..."
|
||||
sudo -u ${SUDO_USER:-$(whoami)} $launch
|
||||
;;
|
||||
N) echo -e $name ;;
|
||||
A) echo -e $author ;;
|
||||
D) echo $description ;;
|
||||
U) echo -e $URL ;;
|
||||
O) echo -e $options ;;
|
||||
S) # Option -S (Get service status)
|
||||
systemctl status $service_name
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo\`."
|
||||
exit 1
|
||||
fi
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args="$@" # arguments to this script
|
||||
interactive="true"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
-h This message
|
||||
Environment - must be first argument:
|
||||
-x User UI is not terminal (script interactive unavailable)
|
||||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-l Command to run software
|
||||
Information:
|
||||
-N Get name
|
||||
-A Get author
|
||||
-D Get description
|
||||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Get Install location
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
)
|
||||
|
||||
### 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 really possible
|
||||
# Arguments to the script are stored in $args
|
||||
# This system supports both interactive and non-interactive installs. For non-interactive installs, $interactive="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="Meshing Around" # software name
|
||||
author="Spud" # software author - OPTIONAL
|
||||
description="Meshing Around is a feature-rich bot designed to enhance your Meshtastic network experience with a variety of powerful tools and fun features. Connectivity and utility through text-based message delivery. Whether you're looking to perform network tests, send messages, or even play games, mesh_bot.py has you covered." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://github.com/SpudGunMan/meshing-around" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedsrNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="mesh_bot pong_bot" # the name of the service, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
location="/opt/meshing-around" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="TC²-BBS, any other \"full control\" style bots" # comma delineated plain-text list of packages with which this package conflicts. 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/spudgunman/meshing-around $location; then
|
||||
echo "user_message: Git clone failed. Is internet connected?"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$interactive" = "true" ]; then #interactive install
|
||||
eval "$location/install.sh"
|
||||
echo "user_message: To change settings, run \`sudo nano $location/config.ini\`"
|
||||
exit 0
|
||||
else
|
||||
echo "user_message: IMPORTANT: To complete installation, run \`sudo $location/install.sh\`\nTo change settings, run \`sudo nano $location/config.ini\`"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
# stop, disable and remove the service, reload systemctl daemon, remove the installation directory and quit
|
||||
systemctl stop $service_name
|
||||
systemctl disable $service_name
|
||||
rm /etc/systemd/system/$service_name.service
|
||||
systemctl daemon-reload
|
||||
rm -rf $location
|
||||
echo "user_message: Service removed, all files deleted."
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
#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
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
x) # Option -x (no user interaction available)
|
||||
echo "Running in non-interactive mode"
|
||||
interactive="false"
|
||||
;;
|
||||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
e) # Option -e (Enable service, if applicable)
|
||||
systemctl enable $service_name
|
||||
;;
|
||||
d) # Option -d (Disable service, if applicable)
|
||||
systemctl disable $service_name
|
||||
;;
|
||||
s) # Option -s (Stop service)
|
||||
systemctl stop $service_name
|
||||
;;
|
||||
r) # Option -r (Start/Restart)
|
||||
systemctl restart $service_name
|
||||
;;
|
||||
l) # Option -l (Run software)
|
||||
echo "Launching $name..."
|
||||
sudo -u ${SUDO_USER:-$(whoami)} $launch
|
||||
;;
|
||||
N) echo -e $name ;;
|
||||
A) echo -e $author ;;
|
||||
D) echo $description ;;
|
||||
U) echo -e $URL ;;
|
||||
O) echo -e $options ;;
|
||||
S) # Option -S (Get service status)
|
||||
systemctl status $service_name
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo\`."
|
||||
exit 1
|
||||
fi
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args="$@" # arguments to this script
|
||||
interaction="true"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
-h This message
|
||||
Environment - must be first argument:
|
||||
-x User UI is not terminal (script interaction unavailable)
|
||||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-l Command to run software
|
||||
Information:
|
||||
-N Get name
|
||||
-A Get author
|
||||
-D Get description
|
||||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Get Install location
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
)
|
||||
|
||||
### 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 really possible
|
||||
# Arguments to the script are stored in $args
|
||||
# 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="name" # software name
|
||||
author="author" # software author - OPTIONAL
|
||||
description="description" # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="URL" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedsrlNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="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/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="package name, other package name" # 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() {
|
||||
echo "user_message: Exit message to user, displayed prominently in post-install"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
echo "user_message: Exit message to user, displayed prominently in post-install"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
|
||||
#upgrade script
|
||||
upgrade() {
|
||||
echo "user_message: Exit message to user, displayed prominently in post-install"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# 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
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
x) # Option -x (no user interaction available)
|
||||
interaction="false"
|
||||
;;
|
||||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
e) # Option -e (Enable service, if applicable)
|
||||
systemctl enable $service_name
|
||||
;;
|
||||
d) # Option -d (Disable service, if applicable)
|
||||
systemctl disable $service_name
|
||||
;;
|
||||
s) # Option -s (Stop service)
|
||||
systemctl stop $service_name
|
||||
;;
|
||||
r) # Option -r (Start/Restart)
|
||||
systemctl restart $service_name
|
||||
;;
|
||||
l) # Option -l (Run software)
|
||||
echo "Launching $name..."
|
||||
sudo -u ${SUDO_USER:-$(whoami)} $launch
|
||||
;;
|
||||
N) echo -e $name ;;
|
||||
A) echo -e $author ;;
|
||||
D) echo $description ;;
|
||||
U) echo -e $URL ;;
|
||||
O) echo -e $options ;;
|
||||
S) # Option -S (Get service status)
|
||||
systemctl status $service_name
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo\`."
|
||||
exit 1
|
||||
fi
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args="$@" # arguments to this script
|
||||
interactive="true"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
-h This message
|
||||
Environment - must be first argument:
|
||||
-x User UI is not terminal (script interactive unavailable)
|
||||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-l Command to run software
|
||||
Information:
|
||||
-N Get name
|
||||
-A Get author
|
||||
-D Get description
|
||||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Get Install location
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
)
|
||||
|
||||
### 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 really possible
|
||||
# Arguments to the script are stored in $args
|
||||
# This system supports both interactive and non-interactive installs. For non-interactive installs, $interactive="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="name" # software name
|
||||
author="author" # software author - OPTIONAL
|
||||
description="description" # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="URL" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedsrlNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="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/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="package name, other package name" # 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() {
|
||||
echo "user_message: Exit message to user, displayed prominently in post-install"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
echo "user_message: Exit message to user, displayed prominently in post-install"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
|
||||
#upgrade script
|
||||
upgrade() {
|
||||
echo "user_message: Exit message to user, displayed prominently in post-install"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# 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
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
x) # Option -x (no user interaction available)
|
||||
interactive="false"
|
||||
;;
|
||||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
e) # Option -e (Enable service, if applicable)
|
||||
systemctl enable $service_name
|
||||
;;
|
||||
d) # Option -d (Disable service, if applicable)
|
||||
systemctl disable $service_name
|
||||
;;
|
||||
s) # Option -s (Stop service)
|
||||
systemctl stop $service_name
|
||||
;;
|
||||
r) # Option -r (Start/Restart)
|
||||
systemctl restart $service_name
|
||||
;;
|
||||
l) # Option -l (Run software)
|
||||
echo "Launching $name..."
|
||||
sudo -u ${SUDO_USER:-$(whoami)} $launch
|
||||
;;
|
||||
N) echo -e $name ;;
|
||||
A) echo -e $author ;;
|
||||
D) echo $description ;;
|
||||
U) echo -e $URL ;;
|
||||
O) echo -e $options ;;
|
||||
S) # Option -S (Get service status)
|
||||
systemctl status $service_name
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
171
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh
Executable file
171
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh
Executable file
|
|
@ -0,0 +1,171 @@
|
|||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo\`."
|
||||
exit 1
|
||||
fi
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args="$@" # arguments to this script
|
||||
interactive="true"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
-h This message
|
||||
Environment - must be first argument:
|
||||
-x User UI is not terminal (script interactive unavailable)
|
||||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-l Command to run software
|
||||
Information:
|
||||
-N Get name
|
||||
-A Get author
|
||||
-D Get description
|
||||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Get Install location
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
)
|
||||
|
||||
### 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 really possible
|
||||
# Arguments to the script are stored in $args
|
||||
# This system supports both interactive and non-interactive installs. For non-interactive installs, $interactive="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="TC2-BBS" # software name
|
||||
author="The Comms Channel" # software author - OPTIONAL
|
||||
description="The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://github.com/TheCommsChannel/TC2-BBS-mesh" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedsrNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="mesh-bbs" # 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/TC2-BBS-mesh" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="Meshing Around, other \"full control\" packages" # 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/TheCommsChannel/TC2-BBS-mesh.git $location; then
|
||||
echo "user_message: Git clone failed. Is internet connected?"
|
||||
exit 1
|
||||
fi
|
||||
chown -R femto $location #give ownership of installation directory to $user
|
||||
git config --global --add safe.directory $location # prevents git error when updating
|
||||
|
||||
cd $location
|
||||
mv example_config.ini config.ini
|
||||
sed -i 's/type = serial/type = tcp/' config.ini
|
||||
sed -i 's/^# hostname = 192.168.x.x/hostname = 127.0.0.1/' config.ini
|
||||
echo "Installation/upgrade successful! Adding/recreating service."
|
||||
sed -i "s/pi/${SUDO_USER:-$(whoami)}/g" $service_name.service
|
||||
sed -i "s|/home/${SUDO_USER:-$(whoami)}/|/opt/|g" $service_name.service
|
||||
sed -i 's|/opt/TC2-BBS-mesh/venv/bin/python3|python|g' mesh-bbs.service
|
||||
cp $service_name.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable $service_name.service
|
||||
systemctl restart $service_name.service
|
||||
|
||||
echo "user_message: Installation complete, service launched. To adjust configuration, run \`sudo nano $location/config.ini\`"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
# stop, disable and remove the service, reload systemctl daemon, remove the installation directory and quit
|
||||
systemctl disable $service_name
|
||||
systemctl stop $service_name
|
||||
rm /etc/systemd/system/$service_name.service
|
||||
systemctl daemon-reload
|
||||
rm -rf $location
|
||||
echo "user_message: Service removed, all files deleted."
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
#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
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
x) # Option -x (no user interaction available)
|
||||
interactive="false"
|
||||
;;
|
||||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
e) # Option -e (Enable service, if applicable)
|
||||
systemctl enable $service_name
|
||||
;;
|
||||
d) # Option -d (Disable service, if applicable)
|
||||
systemctl disable $service_name
|
||||
;;
|
||||
s) # Option -s (Stop service)
|
||||
systemctl stop $service_name
|
||||
;;
|
||||
r) # Option -r (Start/Restart)
|
||||
systemctl restart $service_name
|
||||
;;
|
||||
l) # Option -l (Run software)
|
||||
echo "Launching $name..."
|
||||
sudo -u ${SUDO_USER:-$(whoami)} $launch
|
||||
;;
|
||||
N) echo -e $name ;;
|
||||
A) echo -e $author ;;
|
||||
D) echo $description ;;
|
||||
U) echo -e $URL ;;
|
||||
O) echo -e $options ;;
|
||||
S) # Option -S (Get service status)
|
||||
systemctl status $service_name
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue