Просмотр исходного кода

feat(skeleton): New command skeleton (#3152)

* initial commit of skel

* getopt

* getopt

* getopt

* cpio

* adding messages

* exit

* message

* shellcheck

* truncate netstat for colserver

* added cpio dependency

* tabs
Daniel Gibbs 5 лет назад
Родитель
Сommit
8ab3dccb71

+ 6 - 6
lgsm/functions/check_deps.sh

@@ -343,7 +343,7 @@ fn_deps_build_debian(){
 	array_deps_missing=()
 
 	# LinuxGSM requirements.
-	array_deps_required=( curl wget ca-certificates file bsdmainutils util-linux python3 tar bzip2 gzip unzip binutils bc jq tmux netcat )
+	array_deps_required=( curl wget ca-certificates file bsdmainutils util-linux python3 tar bzip2 gzip unzip binutils bc jq tmux netcat cpio )
 
 	# All servers except ts3, mumble, GTA and minecraft servers require lib32stdc++6 and lib32gcc1.
 	if [ "${shortname}" != "ts3" ]&&[ "${shortname}" != "mumble" ]&&[ "${shortname}" != "mc" ]&&[ "${engine}" != "renderware" ]; then
@@ -470,15 +470,15 @@ fn_deps_build_redhat(){
 	# LinuxGSM requirements.
 	# CentOS
   if [ "${distroversion}" == "7" ]; then
-		array_deps_required=( epel-release curl wget util-linux python3 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat )
+		array_deps_required=( epel-release curl wget util-linux python3 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat cpio )
 	elif [ "${distroversion}" == "8" ]; then
-		array_deps_required=( epel-release curl wget util-linux python36 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat )
+		array_deps_required=( epel-release curl wget util-linux python36 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat cpio )
 	elif [ "${distroid}" == "fedora" ]; then
-			array_deps_required=( curl wget util-linux python3 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat )
+		array_deps_required=( curl wget util-linux python3 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat cpio )
 	elif [[ "${distroname}" == *"Amazon Linux AMI"* ]]; then
-			array_deps_required=( curl wget util-linux python3 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat )
+		array_deps_required=( curl wget util-linux python3 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat cpio )
 	else
-		array_deps_required=( curl wget util-linux python3 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat )
+		array_deps_required=( curl wget util-linux python3 file tar gzip bzip2 unzip binutils bc jq tmux nmap-ncat cpio )
 	fi
 
 	# All servers except ts3, mumble, multi theft auto and minecraft servers require glibc.i686 and libstdc++.i686.

+ 21 - 0
lgsm/functions/command_skeleton.sh

@@ -0,0 +1,21 @@
+#!/bin/bash
+# LinuxGSM command_skeleton.sh function
+# Author: Daniel Gibbs
+# Website: https://linuxgsm.com
+# Description: Creates an copy of a game servers directorys.
+
+
+fn_print_dots "Creating skeleton directory"
+check.sh
+
+# Find all directorys and create them in the skel directory
+find "${rootdir}" -type d -not \( -path ./skel -prune \) | cpio -pdvm skel 2>/dev/null
+exitcode=$?
+if [ "${exitcode}" != 0 ]; then
+	fn_print_fail_nl "Creating skeleton directory"
+	fn_script_log_fatal "Creating skeleton directory"
+else
+	fn_print_ok_nl "Creating skeleton directory: ./skel"
+	fn_script_log_pass "Creating skeleton directory: ./skel"
+fi
+core_exit.sh

+ 5 - 0
lgsm/functions/core_functions.sh

@@ -155,6 +155,11 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 }
 
+command_skeleton.sh(){
+functionfile="${FUNCNAME[0]}"
+fn_fetch_function
+}
+
 command_wipe.sh(){
 functionfile="${FUNCNAME[0]}"
 fn_fetch_function

+ 3 - 2
lgsm/functions/core_getopt.sh

@@ -20,6 +20,7 @@ cmd_backup=( "b;backup" "command_backup.sh" "Create backup archives of the serve
 cmd_update_linuxgsm=( "ul;update-lgsm;uf;update-functions" "command_update_linuxgsm.sh" "Check and apply any LinuxGSM updates." )
 cmd_test_alert=( "ta;test-alert" "command_test_alert.sh" "Send a test alert." )
 cmd_monitor=( "m;monitor" "command_monitor.sh" "Check server status and restart if crashed." )
+cmd_skeleton=( "sk;skeleton" "command_skeleton.sh" "Create a skeleton directory." )
 cmd_donate=( "do;donate" "command_donate.sh" "Donation options." )
 # Console servers only.
 cmd_console=( "c;console" "command_console.sh" "Access server console." )
@@ -55,9 +56,9 @@ cmd_dev_clear_functions=( "cf;clear-functions" "command_dev_clear_functions.sh"
 
 ### Set specific opt here.
 
-currentopt=( "${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_monitor[@]}" "${cmd_test_alert[@]}" "${cmd_details[@]}" "${cmd_postdetails[@]}" )
+currentopt=( "${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_monitor[@]}" "${cmd_test_alert[@]}" "${cmd_details[@]}" "${cmd_postdetails[@]}" "${cmd_skeleton[@]}" )
 
-# Update LGSM.
+# Update LinuxGSM.
 currentopt+=( "${cmd_update_linuxgsm[@]}" )
 
 # Exclude noupdate games here.

+ 1 - 1
lgsm/functions/info_messages.sh

@@ -1446,7 +1446,7 @@ fn_info_message_pavlovvr(){
 }
 
 fn_info_message_colony(){
-	echo -e "netstat -atunp | grep colonyserver"
+	echo -e "netstat -atunp | grep colonyserv"
 	echo -e ""
 	{
 		echo -e "${lightblue}DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL${default}"