Browse Source

chore: added i/o formatting for help script

pull/8291/head
Rohit T P 7 months ago
parent
commit
7022858358
  1. 39
      docker-compose/setup-script/noco.sh

39
docker-compose/setup-script/noco.sh

@ -537,12 +537,18 @@ DOCKER_COMMAND=$([ "$IS_DOCKER_REQUIRE_SUDO" = "y" ] && echo "sudo docker" || ec
cat > ./help.sh <<EOF cat > ./help.sh <<EOF
#!/bin/bash #!/bin/bash
trap show_menu INT
$(declare -f read_number) $(declare -f read_number)
$(declare -f read_number_range) $(declare -f read_number_range)
# Function to display the menu # Function to display the menu
show_menu() { show_menu() {
clear
echo ""
echo \$MSG
echo "Service Management Menu:" echo "Service Management Menu:"
echo "1. Start Service" echo "1. Start Service"
echo "2. Stop Service" echo "2. Stop Service"
@ -568,7 +574,8 @@ stop_service() {
# Function to show logs # Function to show logs
show_logs() { show_logs() {
echo -e "\nSelect a container for logs:" clear
echo "Select a container for logs:"
echo "1. nocodb" echo "1. nocodb"
echo "2. db" echo "2. db"
echo "3. nginx" echo "3. nginx"
@ -602,15 +609,23 @@ upgrade_service() {
# Function to scale the service # Function to scale the service
scale_service() { scale_service() {
NUM_CORES=\$(nproc) num_cores=\$(nproc)
echo "How many instances of NocoDB do you want to run (Maximum: ${NUM_CORES}) ? (default: 1): " current_scale=\$($DOCKER_COMMAND compose ps -q nocodb | wc -l)
\$scale_num=\$(read_number_range 1 \$NUM_CORES) echo -e "\nCurrent number of instances: \$current_scale"
$DOCKER_COMMAND compose up -d --scale nocodb=\$scale_num nocodb echo "How many instances of NocoDB do you want to run (Maximum: \${num_cores}) ? (default: 1): "
scale_num=\$(read_number_range 1 \$num_cores)
if [ \$scale_num -eq \$current_scale ]; then
echo "Number of instances is already set to \$scale_num. Returning to main menu."
return
fi
$DOCKER_COMMAND compose up -d --scale nocodb=\$scale_num
} }
# Function for basic monitoring # Function for basic monitoring
monitoring_service() { monitoring_service() {
echo -e '\nDisplaying basic monitoring info...' echo -e '\nLoading stats...'
$DOCKER_COMMAND stats $DOCKER_COMMAND stats
} }
@ -621,15 +636,15 @@ while true; do
read -n 1 choice read -n 1 choice
case \$choice in case \$choice in
1) start_service ;; 1) start_service && MSG="NocoDB Started" ;;
2) stop_service ;; 2) stop_service && MSG="NocoDB Stopped" ;;
3) show_logs ;; 3) show_logs ;;
4) restart_service ;; 4) restart_service && MSG="NocoDB Restarted" ;;
5) upgrade_service ;; 5) upgrade_service && MSG="NocoDB has been upgraded to latest version" ;;
6) scale_service ;; 6) scale_service && MSG="NocoDB has been scaled" ;;
7) monitoring_service ;; 7) monitoring_service ;;
0) exit 0 ;; 0) exit 0 ;;
*) echo -e "\nInvalid choice. Please select a correct option." ;; *) MSG="\nInvalid choice. Please select a correct option." ;;
esac esac
done done
EOF EOF

Loading…
Cancel
Save