2020-08-01 11:21:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Set up my desktop/laptop with all default setttings that I want.
|
|
|
|
#
|
|
|
|
# uses salt-call masterless configuration.
|
2020-08-02 07:23:41 +00:00
|
|
|
#
|
|
|
|
# to auto answer YES set the INITDESKTOP_YES=1 environment variable
|
2020-08-01 11:21:48 +00:00
|
|
|
|
|
|
|
DOTFILES_REPO="$HOME/.dotfiles"
|
|
|
|
DOTFILES_REMOTE="https://git.rre.nu:443/jonas/dotfiles.git"
|
|
|
|
|
2020-08-02 07:40:50 +00:00
|
|
|
DOTFILES_RENAME_EXISTING_FILES=(
|
|
|
|
.bashrc
|
|
|
|
)
|
|
|
|
|
2020-08-01 11:21:48 +00:00
|
|
|
### NO Changes below this line
|
|
|
|
|
|
|
|
set -aeo pipefail
|
|
|
|
|
2020-08-01 12:06:50 +00:00
|
|
|
function asktobreak(){
|
2020-08-02 07:23:41 +00:00
|
|
|
if [[ "$INITDESKTOP_YES" == 1 ]];then
|
2020-08-02 07:40:50 +00:00
|
|
|
printf "\n"
|
2020-08-02 07:23:41 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2020-08-01 12:06:50 +00:00
|
|
|
printf "Do you want to run this step (y/n)"
|
|
|
|
while read -r -n 1 -s answer; do
|
|
|
|
if [[ $answer == [YyNn] ]];then
|
|
|
|
[[ $answer == [Yy] ]] && return_value=1
|
|
|
|
[[ $answer == [Nn] ]] && return_value=0
|
2020-08-02 07:40:50 +00:00
|
|
|
printf "\n"
|
2020-08-01 12:06:50 +00:00
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return $return_value
|
|
|
|
}
|
2020-08-01 11:21:48 +00:00
|
|
|
function new_log(){
|
|
|
|
# script output
|
2020-08-02 07:40:50 +00:00
|
|
|
printf "\n**** [%s] ***\n" "$*"
|
2020-08-01 11:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function log(){
|
2020-08-02 07:40:50 +00:00
|
|
|
printf "%s\n" "$*"
|
2020-08-01 11:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function gnome_key_bindings(){
|
2020-08-01 12:06:50 +00:00
|
|
|
new_log "Setting my default gnome bindings"
|
|
|
|
if asktobreak; then
|
|
|
|
return
|
|
|
|
fi
|
2020-08-01 11:21:48 +00:00
|
|
|
local KEY_PATH="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings"
|
|
|
|
local CMD="gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:$KEY_PATH"
|
|
|
|
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['$KEY_PATH/custom0/']"
|
|
|
|
|
|
|
|
# Open Terminator
|
2020-08-02 08:07:32 +00:00
|
|
|
$CMD/custom0/ name "Open Terminator"
|
|
|
|
$CMD/custom0/ command "terminator"
|
|
|
|
$CMD/custom0/ binding "<Primary><Alt>Return"
|
2020-08-01 11:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setup_dotfiles(){
|
2020-08-02 07:52:17 +00:00
|
|
|
local dotf="git --git-dir=$DOTFILES_REPO --work-tree=$HOME"
|
2020-08-01 11:21:48 +00:00
|
|
|
new_log "Setting up dotf (dotfiles)"
|
2020-08-01 12:06:50 +00:00
|
|
|
if asktobreak;then
|
|
|
|
return
|
|
|
|
fi
|
2020-08-01 11:21:48 +00:00
|
|
|
log "creating git repo in $DOTFILES_REPO"
|
|
|
|
mkdir "$HOME/.dotfiles"
|
|
|
|
git init --bare "$DOTFILES_REPO"
|
2020-08-02 07:52:17 +00:00
|
|
|
$dotf config --local status.showUntrackedFiles no
|
2020-08-01 11:21:48 +00:00
|
|
|
|
|
|
|
log "adding remote repo ($DOTFILES_REMOTE)"
|
2020-08-02 07:52:17 +00:00
|
|
|
$dotf remote add origin "$DOTFILES_REMOTE"
|
2020-08-01 11:21:48 +00:00
|
|
|
|
2020-08-02 07:40:50 +00:00
|
|
|
|
|
|
|
for file in "${DOTFILES_RENAME_EXISTING_FILES[@]}"; do
|
|
|
|
|
|
|
|
if [[ -f "$HOME/.bashrc" ]];then
|
|
|
|
log "renaming local $file to ${file}.bak"
|
|
|
|
mv "$HOME/$file" "$HOME/${file}.bak"
|
|
|
|
fi
|
|
|
|
done
|
2020-08-01 11:21:48 +00:00
|
|
|
|
2020-08-01 11:43:02 +00:00
|
|
|
log "fetching dotfiles"
|
2020-08-02 07:52:17 +00:00
|
|
|
$dotf fetch origin
|
|
|
|
$dotf checkout master
|
2020-08-01 11:21:48 +00:00
|
|
|
}
|
|
|
|
|
2020-08-01 12:06:50 +00:00
|
|
|
function do_salt_call(){
|
2020-08-01 12:10:23 +00:00
|
|
|
local salt="sudo salt-call --local --file-root $HOME/salt/states --pillar-root $HOME/salt/pillars"
|
2020-08-01 12:06:50 +00:00
|
|
|
new_log "Running salt high state"
|
|
|
|
if asktobreak;then
|
|
|
|
return
|
|
|
|
fi
|
2020-08-02 07:53:52 +00:00
|
|
|
$salt state.apply pillar="{username: $USER}"
|
2020-08-01 12:06:50 +00:00
|
|
|
}
|
2020-08-01 12:08:17 +00:00
|
|
|
|
2020-08-03 08:19:23 +00:00
|
|
|
function firefox_addons(){
|
|
|
|
new_log "Installing firefox addons"
|
|
|
|
if [[ ! -f "$HOME/bin/install_firefox_addon" ]];then
|
|
|
|
printf "install firefox addon script not found, run dotfile sync first"
|
|
|
|
fi
|
|
|
|
if asktobreak;then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
exec $HOME/bin/install_firefox_addon
|
|
|
|
}
|
|
|
|
|
2020-08-01 11:21:48 +00:00
|
|
|
setup_dotfiles
|
2020-08-01 12:08:17 +00:00
|
|
|
do_salt_call
|
2020-08-01 12:55:12 +00:00
|
|
|
gnome_key_bindings
|
2020-08-01 13:02:50 +00:00
|
|
|
|
|
|
|
printf "\n DONE!!!!!!!\n"
|