mirror of
https://github.com/femtofox/femtofox.git
synced 2026-11-20 23:16:30 -05:00
major refactor of software menu and packages
This commit is contained in:
parent
f182e03472
commit
5a15ef3e57
3 changed files with 385 additions and 0 deletions
|
|
@ -0,0 +1,156 @@
|
|||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args="$@"
|
||||
help=$(cat <<EOF
|
||||
Options are:
|
||||
-h This message
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-N Get name
|
||||
-A Get author
|
||||
-D Get description
|
||||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
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
|
||||
|
||||
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 OPTIONAL. Can contain multiple URLs
|
||||
options="iugedsrNADUOS" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
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"
|
||||
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
install() {
|
||||
failedInstall=false
|
||||
#check if /opt/meshing-around exists if not git clone
|
||||
if [ ! -d /opt/meshing-around ]; then
|
||||
dialog --title "$software" --yesno "\nInstallation requires internet connection.\n\nLearn more at \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
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
uninstall() {
|
||||
echo placeholder
|
||||
}
|
||||
|
||||
|
||||
upgrade() {
|
||||
echo placeholder
|
||||
}
|
||||
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
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
|
||||
;;
|
||||
N) echo -e $name ;;
|
||||
A) echo -e $author ;;
|
||||
D) echo -e $description ;;
|
||||
U) echo -e $URL ;;
|
||||
O) echo -e $options ;;
|
||||
S) # Option -S (Get service status)
|
||||
systemctl status $service_name
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args="$@"
|
||||
help=$(cat <<EOF
|
||||
Options are:
|
||||
-h This message
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-N Get name
|
||||
-A Get author
|
||||
-D Get description
|
||||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
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
|
||||
|
||||
name="" # software name
|
||||
author="" # software author OPTIONAL
|
||||
description="" # software description OPTIONAL (but strongly recommended!)
|
||||
URL="" # software URL OPTIONAL. Can contain multiple URLs
|
||||
options="iugedsrNADUOS" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
service_name="" # the name of the service, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
install() {
|
||||
echo placeholder
|
||||
}
|
||||
|
||||
|
||||
uninstall() {
|
||||
echo placeholder
|
||||
}
|
||||
|
||||
|
||||
upgrade() {
|
||||
echo placeholder
|
||||
}
|
||||
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
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
|
||||
;;
|
||||
N) echo -e $name ;;
|
||||
A) echo -e $author ;;
|
||||
D) echo -e $description ;;
|
||||
U) echo -e $URL ;;
|
||||
O) echo -e $options ;;
|
||||
S) # Option -S (Get service status)
|
||||
systemctl status $service_name
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
129
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/tc2_bbs.sh
Executable file
129
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/tc2_bbs.sh
Executable file
|
|
@ -0,0 +1,129 @@
|
|||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
help=$(cat <<EOF
|
||||
Options are:
|
||||
-h This message
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-N Get name
|
||||
-D Get description
|
||||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
EOF
|
||||
)
|
||||
|
||||
name="Tc²-BBS"
|
||||
author="The Comms Channel"
|
||||
description="The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory."
|
||||
URL="https://github.com/TheCommsChannel/TC2-BBS-mesh"
|
||||
options="iugedsrNADUO"
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
install() {
|
||||
dialog --title "$software" --yesno "\nInstallation requires internet connection.\n\nLearn more at \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
|
||||
else
|
||||
return
|
||||
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
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
uninstall() {
|
||||
echo placeholder
|
||||
}
|
||||
|
||||
|
||||
upgrade() {
|
||||
echo placeholder
|
||||
}
|
||||
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
i) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
e) # Option -e (Enable service, if applicable)
|
||||
systemctl enable SERVICENAME
|
||||
;;
|
||||
d) # Option -d (Disable service, if applicable)
|
||||
systemctl disable SERVICENAME
|
||||
;;
|
||||
s) # Option -s (Stop service)
|
||||
systemctl stop SERVICENAME
|
||||
;;
|
||||
r) # Option -r (Start/Restart)
|
||||
systemctl restart SERVICENAME
|
||||
;;
|
||||
D) echo $description ;;
|
||||
U) echo $URL ;;
|
||||
O) echo $options ;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue