# kdsafety **Repository Path**: suretx/kdsafety ## Basic Information - **Project Name**: kdsafety - **Description**: No description available - **Primary Language**: Unknown - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-03-05 - **Last Updated**: 2024-03-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README This repository contains a collection of scripts that I have collected over time during my daily work. The scripts cover various areas including Linux Bash, Windows Batch, and network device configuration commands. 2023.3.30 ## Linux Bash Scripts ### Script 1 - File Backup This script creates a backup of a specified file and appends the current date to the file name. ```bash #!/bin/bash cp /path/to/file /path/to/backup/$(date +%Y-%m-%d)_file_backup ``` ### Script 2 - Service Check This script checks if a specified service is running and restarts it if it is not. ```bash #!/bin/bash if systemctl is-active --quiet service-name.service ; then echo "Service is running" else systemctl start service-name.service echo "Service started" fi ``` ## Windows Batch Scripts ### Script 1 - File Backup This script creates a backup of a specified file and appends the current date to the file name. ```bash @echo off set backup_path=C:\backup set file_path=C:\path\to\file set file_name=file.txt set date=%date:~10,4%-%date:~4,2%-%date:~7,2% copy "%file_path%\%file_name%" "%backup_path%\%date%_%file_name%" ``` ### Script 2 - Service Check This script checks if a specified service is running and restarts it if it is not. ```bash @echo off set service_name=service-name set status=running sc query %service_name% | findstr /i %status% if %errorlevel%==0 ( echo Service is running ) else ( net start %service_name% echo Service started ) ``` ## Network Device Configuration Commands ### Huawei #### Backup Config This command backs up the configuration of a Huawei device to a TFTP server. ```bash sys tftp 10.1.1.1 put flash:/backup.cfg ``` #### VLAN Configuration This command creates a VLAN on a Huawei switch. ```bash vlan 10 description VLAN 10 undo shutdown ``` ### H3C #### Backup Config This command backs up the configuration of a H3C device to a TFTP server. ```bash save configuration to tftp 10.1.1.1 H3C_backup.cfg ``` #### VLAN Configuration This command creates a VLAN on a H3C switch. ```bash vlan 10 name VLAN 10 ```