# Lists the config files found in ~/.config/autodeploy/*.conf
# Lists the config files found in ~/.config/autodeploy/*.conf
echo -e $TICK$GREEN"Listing configs found in $BLUE$CONFIG_PATH"$ENDCOLOR
echo -n $BLUE
echo -e -n $BLUE
ls $CONFIG_PATH| grep "_config$"
ls $CONFIG_PATH| grep "_config$"
}
}
collect_files(){
collect_files(){
echo-e $TICK$GREEN"Collecting files from around the system"$ENDCOLOR
echo$TICK$GREEN"Collecting files from around the system"$ENDCOLOR
# Pulls files from the remote repository and checks to see if the configuration path already exists
# Pulls files from the remote repository and checks to see if the configuration path already exists
git -C $CONFIG_PATH pull origin main --allow-unrelated-histories > /dev/null 2>&1
git -C $CONFIG_PATH pull origin main --allow-unrelated-histories > /dev/null 2>&1
# Check if the configuration path already exists
# Check if the configuration path already exists
echo-e $TICK$GREEN"Moving files"$ENDCOLOR
echo$TICK$GREEN"Moving files"$ENDCOLOR
iftest -d $HOST_CONFIG_PATH;then
iftest -d $HOST_CONFIG_PATH;then
echo-e $TICK$GREEN"Creating files in $BLUE$CONFIG_PATH/$(hostname)_config"$ENDCOLOR
echo$TICK$GREEN"Creating files in $BLUE$CONFIG_PATH/$(hostname)_config"$ENDCOLOR
else
else
mkdir -p $HOST_CONFIG_PATH
mkdir -p $HOST_CONFIG_PATH
echo-e $TICK$GREEN"Creating files in $BLUE$CONFIG_PATH/$(hostname)_config"$ENDCOLOR
echo$TICK$GREEN"Creating files in $BLUE$CONFIG_PATH/$(hostname)_config"$ENDCOLOR
fi
fi
# Copy each line in $CONFIG_PATH/autodeploy_files.conf to $HOST_CONFIG_PATH
# Copy each line in $CONFIG_PATH/autodeploy_files.conf to $HOST_CONFIG_PATH
@ -147,12 +144,12 @@ collect_files(){
# Copies all files listed in $HOST_CONFIG_PATH/autodeploy_files.conf recursively, verbosely, and forcefully to the staging area. Filters out un-needed lines, and logs them to $hostname_files.log
# Copies all files listed in $HOST_CONFIG_PATH/autodeploy_files.conf recursively, verbosely, and forcefully to the staging area. Filters out un-needed lines, and logs them to $hostname_files.log
cp -rvf --parents $line$HOST_CONFIG_PATH 2> /dev/null | grep "^'"| awk '{print $1}'| sed "s/'//g"| sed 's@'"$HOME"'@$HOME@' 2>/dev/null
cp -rvf --parents $line$HOST_CONFIG_PATH 2> /dev/null | grep "^'"| awk '{print $1}'| sed "s/'//g"| sed 's@'"$HOME"'@$HOME@' 2>/dev/null
# Going to need to add sorting somewhere in here because this log will keep growing
# Going to need to add sorting somewhere in here because this log will keep growing
echo-e $TICK_MOVE$GREEN" Copying $BLUE$line$GREEN to $BLUE$HOST_CONFIG_PATH$GREEN if file exists"$ENDCOLOR
echo$TICK_MOVE$GREEN" Copying $BLUE$line$GREEN to $BLUE$HOST_CONFIG_PATH$GREEN if file exists"$ENDCOLOR
echo-e $TICK$GREEN"Configuration files saved to $BLUE$HOST_CONFIG_PATH$GREEN. Files can be pushed to $BLUE$remote_repo$GREEN with$BLUE autodeploy -p$GREEN"$ENDCOLOR
echo$TICK$GREEN"Configuration files saved to $BLUE$HOST_CONFIG_PATH$GREEN. Files can be pushed to $BLUE$remote_repo$GREEN with$BLUE autodeploy -p$GREEN"$ENDCOLOR
}
}
@ -170,7 +167,7 @@ edit_files() {
}
}
move_dev(){
move_dev(){
if[ -z "$2"];then
if[ -z "$2"];then
echo-e $TICK$GREEN"No arguments supplied, using configuration in $BLUE$HOST_CONFIG_PATH"$ENDCOLOR
echo$TICK$GREEN"No arguments supplied, using configuration in $BLUE$HOST_CONFIG_PATH"$ENDCOLOR
collect_files
collect_files
else
else
select_config "$@"
select_config "$@"
@ -179,10 +176,10 @@ move_dev(){
}
}
select_config(){
select_config(){
echo-e $TICK_ERROR$YELLOW"Please specify the name of the config file you wish to use"$ENDCOLOR
echo$TICK_ERROR$YELLOW"Please specify the name of the config file you wish to use"$ENDCOLOR
selected_config=$2
selected_config=$2
iftest -d "$CONFIG_PATH/$selected_config";then
iftest -d "$CONFIG_PATH/$selected_config";then
echo-e $TICK$GREEN"$selected_config selected"
echo$TICK$GREEN"$selected_config selected"
distribute_files
distribute_files
else
else
list_configs
list_configs
@ -193,17 +190,17 @@ select_config(){
check_git(){
check_git(){
# Check if the autodeploy configuration files are are in the current repo. If not, creates them
# Check if the autodeploy configuration files are are in the current repo. If not, creates them
if ! test -f "$CONFIG_PATH/autodeploy_files.conf";then
if ! test -f "$CONFIG_PATH/autodeploy_files.conf";then
echo-e $TICK$GREEN"Config file not found, generating base configuration..."$ENDCOLOR
echo$TICK$GREEN"Config file not found, generating base configuration..."$ENDCOLOR