mirror of
https://github.com/femtofox/femtofox.git
synced 2026-11-20 15:06:36 -05:00
add curses client to package manager
This commit is contained in:
parent
a5b9a5b5c6
commit
d4d4a0bea9
4 changed files with 300 additions and 83 deletions
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
|
||||
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
|
||||
# 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)
|
||||
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
|
||||
|
|
@ -7,8 +7,10 @@ fi
|
|||
args="$@"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
Actions:
|
||||
-h This message
|
||||
Environment - must be first argument:
|
||||
-x User UI is not terminal (script interaction unavailable)
|
||||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
|
|
@ -23,8 +25,8 @@ Arguments:
|
|||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Install location
|
||||
-C Conflicts
|
||||
-L Get Install location
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
)
|
||||
|
|
@ -34,16 +36,16 @@ EOF
|
|||
# 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
|
||||
# For install/uninstall/upgrade, output should be given as echo or printf
|
||||
# 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
|
||||
# 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
|
||||
# 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="iugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiugedsrNADUOSLCIto" # 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"
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,22 @@
|
|||
#!/bin/bash
|
||||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`."
|
||||
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:
|
||||
Actions:
|
||||
-h This message
|
||||
Environment - must be first argument:
|
||||
-x User UI is not terminal (script interaction unavailable)
|
||||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-g Upgrade
|
||||
|
|
@ -16,6 +24,7 @@ Arguments:
|
|||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-l Command to run software
|
||||
Information:
|
||||
-N Get name
|
||||
-A Get author
|
||||
|
|
@ -34,9 +43,9 @@ EOF
|
|||
# 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
|
||||
# For install/uninstall/upgrade, output should be given as echo or printf
|
||||
# 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
|
||||
# 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"`.
|
||||
# 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
|
||||
|
||||
|
||||
|
|
@ -44,48 +53,38 @@ 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="iugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
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"
|
||||
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# install script
|
||||
install() {
|
||||
echo "user_message: Exit message to user, displayed prominently in post-install"
|
||||
exit 0 # should be `exit 1` if the installation failed
|
||||
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 the installation failed
|
||||
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 the installation failed
|
||||
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
|
||||
#echo "Already installed"
|
||||
exit 0
|
||||
else
|
||||
#echo "Not installed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
|
@ -95,6 +94,9 @@ while getopts ":h$options" opt; do
|
|||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
x) # Option -x (no user interaction available)
|
||||
interaction="false"
|
||||
;;
|
||||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
|
|
@ -116,9 +118,13 @@ while getopts ":h$options" opt; do
|
|||
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 -e $description ;;
|
||||
D) echo $description ;;
|
||||
U) echo -e $URL ;;
|
||||
O) echo -e $options ;;
|
||||
S) # Option -S (Get service status)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
#!/bin/bash
|
||||
#!/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
|
||||
interaction="true"
|
||||
help=$(cat <<EOF
|
||||
Options are:
|
||||
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
|
||||
|
|
@ -14,18 +19,39 @@ Options are:
|
|||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
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
|
||||
)
|
||||
|
||||
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"
|
||||
### 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
|
||||
# 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`
|
||||
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"
|
||||
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
|
|
@ -34,61 +60,62 @@ if [ $# -eq 0 ]; then
|
|||
fi
|
||||
|
||||
|
||||
# install script
|
||||
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
|
||||
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."
|
||||
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
|
||||
systemctl enable mesh-bbs.service
|
||||
systemctl restart mesh-bbs.service
|
||||
|
||||
# for whatever reason, this is necessary
|
||||
sleep 5
|
||||
sudo systemctl restart mesh-bbs
|
||||
|
||||
#dialog --title "$software" --msgbox "\nInstallation complete." 8 50
|
||||
echo "user_message: Installation complete, service launched. To adjust configuration, run \`sudo nano $location/config.ini\`"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
echo placeholder
|
||||
systemctl disable mesh-bbs.service
|
||||
systemctl stop mesh-bbs.service
|
||||
rm -rf $location
|
||||
echo "user_message: Service removed, all files deleted."
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
#upgrade script
|
||||
upgrade() {
|
||||
echo placeholder
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -97,30 +124,43 @@ while getopts ":h$options" opt; do
|
|||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
x) # Option -x (no user interaction available)
|
||||
interaction="false"
|
||||
;;
|
||||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
i) # Option -u (uninstall)
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
e) # Option -e (Enable service, if applicable)
|
||||
systemctl enable SERVICENAME
|
||||
systemctl enable $service_name
|
||||
;;
|
||||
d) # Option -d (Disable service, if applicable)
|
||||
systemctl disable SERVICENAME
|
||||
systemctl disable $service_name
|
||||
;;
|
||||
s) # Option -s (Stop service)
|
||||
systemctl stop SERVICENAME
|
||||
systemctl stop $service_name
|
||||
;;
|
||||
r) # Option -r (Start/Restart)
|
||||
systemctl restart SERVICENAME
|
||||
systemctl restart $service_name
|
||||
;;
|
||||
D) echo $description ;;
|
||||
U) echo $URL ;;
|
||||
O) echo $options ;;
|
||||
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
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue