|
|
|
@ -12,6 +12,7 @@ HOST_CONFIG_PATH=~/.config/autodeploy/$(hostname)_config/
|
|
|
|
|
user=$(hostname)
|
|
|
|
|
usage() { echo "Usage: $0 [-s <45|90>] [-p <string>]" 1>&2; exit 1; } # Copy and pasted, need to update
|
|
|
|
|
|
|
|
|
|
clear
|
|
|
|
|
echo $GREEN"-------------------------------------------------------------------"$ENDCOLOR
|
|
|
|
|
echo $GREEN"*** $BLUE AutoDeploy - A pure bash configuration management tool$GREEN ***"$ENDCOLOR
|
|
|
|
|
echo $GREEN"-------------------------------------------------------------------"$ENDCOLOR
|
|
|
|
@ -20,18 +21,20 @@ first_setup(){
|
|
|
|
|
echo $TICK$GREEN"Running first time setup"$ENDCOLOR
|
|
|
|
|
echo $TICK$GREEN"Creating Configuration Files in $BLUE~/.config/autodeploy/ "$ENDCOLOR
|
|
|
|
|
mkdir -p ~/.config/autodeploy/
|
|
|
|
|
echo $TICK$GREEN"Add your git repository by editing $BLUE~/.config/autodeploy/config.conf"$ENDCOLOR # Change this to accept user input
|
|
|
|
|
echo "config_name=$(hostname)" > $CONFIG_PATH/config.conf
|
|
|
|
|
echo "remote_repo="http://iroh.int/Graham/ConfigFiles.git"" >> $CONFIG_PATH/config.conf
|
|
|
|
|
. ~/.config/autodeploy/config.conf
|
|
|
|
|
echo $TICK$GREEN"Add your git repository by editing $BLUE~/.config/autodeploy/global_config.conf"$ENDCOLOR # Change this to accept user input
|
|
|
|
|
echo "config_name=$(hostname)" > $CONFIG_PATH/global_config.conf
|
|
|
|
|
echo "remote_repo="http://iroh.int/Graham/ConfigFiles.git"" >> $CONFIG_PATH/global_config.conf
|
|
|
|
|
. ~/.config/autodeploy/global_config.conf
|
|
|
|
|
cd $CONFIG_PATH
|
|
|
|
|
git init > /dev/null 2>&1;
|
|
|
|
|
git remote add origin $remote_repo > /dev/null 2>&1;
|
|
|
|
|
git checkout -b main> /dev/null 2>&1;
|
|
|
|
|
|
|
|
|
|
echo "config_name=$(hostname)" > $CONFIG_PATH/config.conf
|
|
|
|
|
echo "remote_repo="http://iroh.int:80/Graham/ConfigFiles.git"" >> $CONFIG_PATH/config.conf
|
|
|
|
|
. $CONFIG_PATH/config.conf
|
|
|
|
|
echo "config_name=$(hostname)" > $CONFIG_PATH/global_config.conf
|
|
|
|
|
echo "remote_repo="http://iroh.int:80/Graham/ConfigFiles.git"" >> $CONFIG_PATH/global_config.conf
|
|
|
|
|
echo "neovim\nmupdf" >> $CONFIG_PATH/global_applications.conf
|
|
|
|
|
echo "~/.tmux" >> $CONFIG_PATH/global_dotFiles.conf
|
|
|
|
|
. $CONFIG_PATH/global_config.conf
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -97,18 +100,21 @@ install_apt(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage_files(){
|
|
|
|
|
git -C $CONFIG_PATH pull
|
|
|
|
|
# Grab files from around the system and move them to $CONFIG_PATH
|
|
|
|
|
echo $TICK$GREEN"Staging Files!"$ENDCOLOR
|
|
|
|
|
if test -d $HOST_CONFIG_PATH;then
|
|
|
|
|
echo $TICK$GREEN"Config file already found in $BLUE$CONFIG_PATH/$(hostname)_config"$ENDCOLOR
|
|
|
|
|
echo $TAB$TICK$GREEN"Config file already found in $BLUE$CONFIG_PATH/$(hostname)_config"$ENDCOLOR
|
|
|
|
|
else
|
|
|
|
|
mkdir -p $HOST_CONFIG_PATH
|
|
|
|
|
echo $TICK$GREEN"Created config file in $BLUE$CONFIG_PATH/$(hostname)_config"$ENDCOLOR
|
|
|
|
|
fi
|
|
|
|
|
# Copy each line in $CONFIG_PATH/files.conf to $HOST_CONFIG_PATH
|
|
|
|
|
# Copy each line in $CONFIG_PATH/global_dotFiles.conf to $HOST_CONFIG_PATH
|
|
|
|
|
while read line; do
|
|
|
|
|
cp -rf $HOME/$line $HOST_CONFIG_PATH
|
|
|
|
|
echo $TICK_MOVE$GREEN"Copied $BLUE$line$GREEN to $BLUE$HOST_CONFIG_PATH"$ENDCOLOR
|
|
|
|
|
done < $CONFIG_PATH/files.conf
|
|
|
|
|
done < $CONFIG_PATH/global_dotFiles.conf
|
|
|
|
|
echo $TICK$GREEN"Configuration files saved to $BLUE$HOST_CONFIG_PATH$GREEN, ready to push!"$ENDCOLOR
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -116,24 +122,20 @@ remote_push(){
|
|
|
|
|
# Push files to $remote_repo
|
|
|
|
|
cd $CONFIG_PATH
|
|
|
|
|
echo $TICK$GREEN"Adding Files"$ENDCOLOR
|
|
|
|
|
git add $HOST_CONFIG_PATH
|
|
|
|
|
git add .
|
|
|
|
|
echo $TICK$GREEN"Commiting"$ENDCOLOR
|
|
|
|
|
git commit -m "Autodeploy from $(hostname) on $(date)"
|
|
|
|
|
echo $TICK$GREEN"Pushing"$ENDCOLOR
|
|
|
|
|
git push -u origin main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
git push -u origin main --force
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main(){
|
|
|
|
|
if !(test -d $CONFIG_PATH);then
|
|
|
|
|
first_setup
|
|
|
|
|
else
|
|
|
|
|
echo "not first time"
|
|
|
|
|
fi
|
|
|
|
|
#stage_files
|
|
|
|
|
#remote_push
|
|
|
|
|
stage_files
|
|
|
|
|
remote_push
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main
|
|
|
|
|