-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added config files to run the script
- Loading branch information
1 parent
0f61c2b
commit d331ca6
Showing
9 changed files
with
213 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[CopyTask1] | ||
source="/path/to/source/file1" | ||
destination="/path/to/destination/file1" | ||
|
||
[CopyTask2] | ||
source="/path/to/source/file2" | ||
destination="/path/to/destination/file2" | ||
|
||
[CopyTask3] | ||
source="/path/to/source/file3" | ||
destination="/path/to/destination/file3" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CopyTask1,/path/to/source/file1,/path/to/destination/file1 | ||
CopyTask2,/path/to/source/file2,/path/to/destination/file2 | ||
CopyTask3,/path/to/source/file3,/path/to/destination/file3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#Config file | ||
SCANPORT=6666 #mpd service | ||
SSHPORT=2222 | ||
IDENTITY_KEY="~/laptopkey" | ||
HOSTDOMAIN="laptop.local" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
service1,6800,6800 | ||
rtmp,1935,1935 | ||
emby,8096,8096 | ||
webserver,8080,80 | ||
mpd,6666,6666 | ||
kodiremote,8081,8085 | ||
service3,4533,4533 | ||
ssl,4445,445 | ||
service4,4533,4533 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Function to copy files | ||
copy_files() { | ||
local source="$1" | ||
local destination="$2" | ||
|
||
# Check if source file exists | ||
if [[ -f "$source" ]]; then | ||
# Copy source to destination | ||
#cp "$source" "$destination" | ||
echo "Copied: $source -> $destination" | ||
else | ||
echo "Source file not found: $source" | ||
fi | ||
} | ||
|
||
# Load the configuration file and parse it line by line | ||
if [[ -f "service.csv" ]]; then | ||
while IFS=',' read -r task source destination; do | ||
echo "running $task " | ||
copy_files "$source" "$destination" | ||
done < "./service.csv" | ||
else | ||
echo "Configuration file 'config.csv' not found." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Function to copy files | ||
copy_files() { | ||
local source="$1" | ||
local destination="$2" | ||
|
||
# Check if source file exists | ||
if [[ -f "$source" ]]; then | ||
# Copy source to destination | ||
cp "$source" "$destination" | ||
echo "Copied: $source -> $destination" | ||
else | ||
echo "Source file not found: $source" | ||
fi | ||
} | ||
|
||
# Load the configuration file | ||
if [[ -f "config.conf" ]]; then | ||
. "config.conf" | ||
else | ||
echo "Configuration file 'config.conf' not found." | ||
exit 1 | ||
fi | ||
|
||
# Loop through sections in the configuration file | ||
for section in $(cat "config.conf" | grep -E "^\[.*\]$"); do | ||
section="${section#[}" | ||
section="${section%]}" | ||
|
||
# Read source and destination from the section | ||
source="${section}_source" | ||
destination="${section}_destination" | ||
|
||
# Check if both source and destination are defined | ||
if [[ -v "$source" && -v "$destination" ]]; then | ||
copy_files "${!source}" "${!destination}" | ||
else | ||
echo "Missing source or destination in section: $section" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# Declare an associative array to store source and destination | ||
declare -A file_mapping | ||
|
||
# Function to copy files | ||
copy_files() { | ||
local source="$1" | ||
local destination="$2" | ||
|
||
# Check if source file exists | ||
if [[ -f "$source" ]]; then | ||
# Copy source to destination | ||
# cp "$source" "$destination" | ||
echo "Copied: $source -> $destination" | ||
else | ||
echo "Source file not found: $source" | ||
fi | ||
} | ||
|
||
# Load the configuration file and parse it line by line | ||
if [[ -f "config.csv" ]]; then | ||
while IFS=',' read -r task source destination; do | ||
echo "running $task " | ||
copy_files "$source" "$destination" | ||
|
||
# Modify $task to ensure it's a valid array key | ||
# Remove spaces and problematic characters | ||
task=${task//[^a-zA-Z0-9_]/_} | ||
|
||
# Append source and destination to the associative array | ||
file_mapping["$task"]=$source:$destination | ||
done < "config.csv" | ||
|
||
# Print the associative array for reference | ||
for key in "${!file_mapping[@]}"; do | ||
echo "Task: $key, Source-Destination: ${file_mapping[$key]}" | ||
done | ||
else | ||
echo "Configuration file 'config.csv' not found." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Function to copy files | ||
copy_files() { | ||
local source="$1" | ||
local destination="$2" | ||
|
||
# Check if source file exists | ||
if [[ -f "$source" ]]; then | ||
# Copy source to destination | ||
#cp "$source" "$destination" | ||
echo "Copied: $source -> $destination" | ||
else | ||
echo "Source file not found: $source" | ||
fi | ||
} | ||
|
||
# Load the configuration file and parse it line by line | ||
if [[ -f "service.csv" ]]; then | ||
while IFS=',' read -r task source destination; do | ||
echo "ports for $task is $source and $destination " | ||
done < "./service.csv" | ||
else | ||
echo "Configuration file 'config.csv' not found." | ||
exit 1 | ||
fi |