Zyan11/LocalAI-Amlan-Edition
5
1#!/bin/bash2 3# This file contains some really simple functions that are useful when building up customization scripts.4 5 6# Checks if the git config has a user registered - and sets it up if not.7#8# Param 1: name9# Param 2: email10#11config_user() {12 echo "Configuring git for $1 <$2>"13 local gcn=$(git config --global user.name)14 if [ -z "${gcn}" ]; then15 echo "Setting up git user / remote"16 git config --global user.name "$1"17 git config --global user.email "$2"18 19 fi20}21 22# Checks if the git remote is configured - and sets it up if not. Fetches either way.23#24# Param 1: remote name25# Param 2: remote url26#27config_remote() {28 echo "Adding git remote and fetching $2 as $1"29 local gr=$(git remote -v | grep $1)30 if [ -z "${gr}" ]; then31 git remote add $1 $232 fi33 git fetch $134}35 36# Setup special .ssh files37# Prints out lines of text to make things pretty38# Param 1: bash array, filenames relative to the customization directory that should be copied to ~/.ssh39setup_ssh() {40 echo "starting ~/.ssh directory setup..."41 mkdir -p "${HOME}.ssh"42 chmod 0700 "${HOME}/.ssh"43 echo "-----"44 local files=("$@")45 for file in "${files[@]}" ; do46 local cfile="/devcontainer-customization/${file}"47 local hfile="${HOME}/.ssh/${file}"48 if [ ! -f "${hfile}" ]; then49 echo "copying \"${file}\""50 cp "${cfile}" "${hfile}"51 chmod 600 "${hfile}"52 fi53 done54 echo "~/.ssh directory setup complete!"55}56 