mirror of
https://github.com/femtofox/femtofox.git
synced 2026-12-04 22:00:21 -05:00
allow samba (and meshing around) initialization from menu
This commit is contained in:
parent
03dddff716
commit
8521180d78
4 changed files with 66 additions and 19 deletions
|
|
@ -39,6 +39,21 @@ uninstall() {
|
|||
fi
|
||||
}
|
||||
|
||||
initialize() {
|
||||
dialog --no-collapse --title "$title" --yesno "\nIntialize $($package_dir/$1.sh -N)\n\nInitialization runs commands that frequently require user interaction and so can only be run from terminal.\n\nProceed?" 13 50
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
clear
|
||||
echo "Initializing $($package_dir/$1.sh -N)..."
|
||||
eval "$package_dir/$1.sh -a"
|
||||
if [ $? -eq 0 ]; then # if the installation was successful
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\nInitialization of $($package_dir/$1.sh -N) successful!" 8 50 # if there's a user_message, display it with two preceeding line breaks
|
||||
else
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\nInitialization of $($package_dir/$1.sh -N) FAILED!" 8 50 # if there's a user_message, display it with two preceeding line breaks
|
||||
fi
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
dialog --no-collapse --title "$title" --yesno "\nUpgrade $($package_dir/$1.sh -N)\n\nProceed?" 10 40
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
|
|
@ -54,7 +69,6 @@ upgrade() {
|
|||
else
|
||||
dialog --no-collapse --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
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -80,10 +94,11 @@ 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 --no-collapse --title "$title" --cancel-label "Back" --default-item "$choice" --menu "$($package_dir/$1.sh -N)" 17 45 5 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "Back" --default-item "$choice" --menu "$($package_dir/$1.sh -N)" 18 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 'a' && $package_dir/$1.sh -I; then echo "Initialize 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) \
|
||||
|
|
@ -104,6 +119,7 @@ package_menu() {
|
|||
"Run software") eval "$package_dir/$1.sh -l" ;;
|
||||
"Install") install $1 ;;
|
||||
"Uninstall") uninstall $1 ;;
|
||||
"Initialize") initialize $1 ;;
|
||||
"Upgrade") upgrade $1 ;;
|
||||
"Enable service") echo "Enabling and starting service..." && eval "$package_dir/$1.sh -e" && eval "$package_dir/$1.sh -r" ;;
|
||||
"Disable service") echo "Disabling and stopping service..." && eval "$package_dir/$1.sh -d" && eval "$package_dir/$1.sh -s" ;;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ Arguments:
|
|||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
|
|
@ -52,7 +53,7 @@ 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="xiugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiuagedsrNADUOSLCI" # 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 mesh_bot_reporting" # 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`
|
||||
|
|
@ -65,16 +66,13 @@ install() {
|
|||
exit 1
|
||||
fi
|
||||
if [ "$interactive" = "true" ]; then #interactive install
|
||||
"$location/install.sh" | tee /dev/tty
|
||||
echo "user_message: To change settings, run \`sudo nano $location/config.ini\`"
|
||||
exit 0
|
||||
interactive_init
|
||||
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
|
||||
|
|
@ -96,6 +94,12 @@ uninstall() {
|
|||
exit 0
|
||||
}
|
||||
|
||||
# code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
interactive_init() {
|
||||
"$location/install.sh" | tee /dev/tty
|
||||
echo "user_message: To change settings, run \`sudo nano $location/config.ini\`"
|
||||
exit 0
|
||||
}
|
||||
|
||||
#upgrade script
|
||||
upgrade() {
|
||||
|
|
@ -129,6 +133,9 @@ while getopts ":h$options" opt; do
|
|||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
a) # Option -a (interactive initialization)
|
||||
interactive_init
|
||||
;;
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ if [ $# -eq 0 ]; then
|
|||
fi
|
||||
|
||||
args="$@" # arguments to this script
|
||||
interaction="true"
|
||||
interactive="true"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
-h This message
|
||||
|
|
@ -19,6 +19,7 @@ Arguments:
|
|||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
|
|
@ -47,13 +48,12 @@ EOF
|
|||
# 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
|
||||
hxiugedsrlNADUOSLCI
|
||||
|
||||
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="xiugedsrlNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiuagedsrlNADUOSLCI" # 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"
|
||||
package_name="apt_package" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't
|
||||
|
|
@ -69,13 +69,16 @@ 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
|
||||
}
|
||||
|
||||
# code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
interactive_init() {
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# upgrade script
|
||||
upgrade() {
|
||||
|
|
@ -114,6 +117,9 @@ while getopts ":h$options" opt; do
|
|||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
a) # Option -a (interactive initialization)
|
||||
interactive_init
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ if [ $# -eq 0 ]; then
|
|||
fi
|
||||
|
||||
args="$@" # arguments to this script
|
||||
interaction="true"
|
||||
interactive="true"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
-h This message
|
||||
|
|
@ -19,6 +19,7 @@ Arguments:
|
|||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
|
|
@ -48,12 +49,14 @@ EOF
|
|||
# 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
|
||||
|
||||
user_message="To connect to network share, enter \`\\\\\\\\femtofox\\home\` from Windows, \`smb://$(hostname)\\home\` from MacOS or \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`."
|
||||
init_instructions="To enable file sharing, run \`Initialize\` in the femto-config Samba menu, or enable the Samba service, run \`sudo smbpasswd -a femto\` to set a Samba password, and then restart the Samba service."
|
||||
|
||||
name="Samba File Sharing" # software name
|
||||
author="Software Freedom Conservancy" # software author - OPTIONAL
|
||||
description="Femtofox comes with Samba preinstalled but disabled. To enable file sharing, run \`sudo smbpasswd -a femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nSamba is an open-source implementation of the SMB/CIFS protocol that enables file and printer sharing between Linux/Unix and Windows systems. It allows Linux machines to act as file servers, domain controllers, or Active Directory members, making them accessible from Windows and other SMB-compatible clients.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`." # software description - OPTIONAL (but strongly recommended!)
|
||||
description="Femtofox comes with Samba preinstalled but disabled. $init_instructions\n\n$user_message" # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://www.samba.org/" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiuagedsrNADUOSCI" # 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="smbd nmbd" # 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="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
|
|
@ -63,13 +66,16 @@ conflicts="" # comma delineated plain-text list of packages with which this pa
|
|||
# install script
|
||||
install() {
|
||||
echo "apt update can take a long while..."
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; }
|
||||
echo -e "user_message: IMPORTANT: To complete installation, enable the Samba service, run \`sudo smbpasswd -a femto\` to set a Samba password, and restart the Samba service.\nTo connect to network share, enter \`\\\\\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`."
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
# DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
|
||||
# DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; }
|
||||
if [ "$interactive" = "true" ]; then # interactive install
|
||||
interactive_init
|
||||
else # noninteractive installation (such as web-UI)
|
||||
echo -e "user_message: IMPORTANT: $init_instructions\n\n$user_message"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
DEBIAN_FRONTEND=noninteractive apt remove -y $package_name 2>&1 | tee /dev/tty
|
||||
|
|
@ -79,6 +85,15 @@ uninstall() {
|
|||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
interactive_init() {
|
||||
$(basename "$0" -e)
|
||||
echo -e "\nSet user \`Femto\` login password:"
|
||||
smbpasswd -a femto
|
||||
$(basename "$0" -r)
|
||||
echo -e "user_message: Samba initialized, and service enabled and started. $user_message"
|
||||
exit 0
|
||||
}
|
||||
|
||||
#upgrade script
|
||||
upgrade() {
|
||||
|
|
@ -108,6 +123,9 @@ while getopts ":h$options" opt; do
|
|||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
a) # Option -a (interactive initialization)
|
||||
interactive_init
|
||||
;;
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue