209 lines
5.0 KiB
Bash
Executable File
209 lines
5.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Set up my desktop/laptop with all default setttings that I want.
|
|
#
|
|
# uses salt-call masterless configuration.
|
|
#
|
|
# to auto answer YES set the INITDESKTOP_YES=1 environment variable
|
|
|
|
DOTFILES_REPO="$HOME/.dotfiles"
|
|
DOTFILES_REMOTE="https://git.rre.nu:443/jonas/dotfiles.git"
|
|
|
|
DOTFILES_RENAME_EXISTING_FILES=(
|
|
.bashrc
|
|
)
|
|
|
|
### NO Changes below this line
|
|
|
|
set -aeo pipefail
|
|
|
|
function printHelp(){
|
|
cat << EOF
|
|
Usage ${0##*/} [options..]
|
|
-h,-?, --help Show help and exit
|
|
-f, --firefox configure firefox and install addons
|
|
-g, --gnome configure gnome and install extentions
|
|
-d, --dotfiles configure dotfiles
|
|
-s, --salt run a masterless salt-call
|
|
-y, --yes answer 'yes' on all questions
|
|
EOF
|
|
}
|
|
|
|
|
|
function asktobreak(){
|
|
if [[ "$ANSWER_YES" == true ]];then
|
|
printf "\n"
|
|
return 1
|
|
fi
|
|
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
|
|
printf "\n"
|
|
break;
|
|
fi
|
|
done
|
|
return $return_value
|
|
}
|
|
function new_log(){
|
|
# script output
|
|
printf "\n**** [%s] ***\n" "$*"
|
|
}
|
|
|
|
function log(){
|
|
printf "%s\n" "$*"
|
|
}
|
|
|
|
function gnome_config(){
|
|
new_log "Setting my default gnome bindings"
|
|
log "WARNING! All running firefox instances will be killed"
|
|
if asktobreak; then
|
|
return
|
|
fi
|
|
set +e
|
|
pkill -f firefox
|
|
set -e
|
|
log "Launching firefox to install GNOME Extetions"
|
|
firefox https://extensions.gnome.org/extension/1031/topicons/
|
|
firefox https://extensions.gnome.org/extension/600/launch-new-instance/
|
|
firefox https://extensions.gnome.org/extension/921/multi-monitors-add-on/
|
|
|
|
log "loading dconf settings"
|
|
dconf load < cat <<EOF
|
|
[system/locale]
|
|
region='sv_SE.UTF-8'
|
|
|
|
|
|
[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0]
|
|
binding='<Primary><Alt>Return'
|
|
command='terminator'
|
|
name='Open Terminator'
|
|
|
|
[org/gnome/evolution-data-server/calendar]
|
|
|
|
[org/gnome/shell]
|
|
enabled-extensions=['TopIcons@phocean.net', 'multi-monitors-add-on@spin83', 'launch-new-instance@gnome-shell-extensions.gcampax.github.com']
|
|
|
|
[org/gnome/shell/extensions/topicons]
|
|
icon-opacity=221
|
|
tray-pos='right'
|
|
tray-order=1
|
|
|
|
|
|
[org/gnome/shell/extensions/multi-monitors-add-on]
|
|
show-activities=false
|
|
show-app-menu=false
|
|
available-indicators=@as []
|
|
show-date-time=false
|
|
show-panel=false
|
|
thumbnails-on-left-side=false
|
|
show-thumbnails-slider=false
|
|
EOF
|
|
|
|
}
|
|
|
|
function setup_dotfiles(){
|
|
local dotf="git --git-dir=$DOTFILES_REPO --work-tree=$HOME"
|
|
new_log "Setting up dotf (dotfiles)"
|
|
if asktobreak;then
|
|
return
|
|
fi
|
|
log "creating git repo in $DOTFILES_REPO"
|
|
mkdir "$HOME/.dotfiles"
|
|
git init --bare "$DOTFILES_REPO"
|
|
$dotf config --local status.showUntrackedFiles no
|
|
|
|
log "adding remote repo ($DOTFILES_REMOTE)"
|
|
$dotf remote add origin "$DOTFILES_REMOTE"
|
|
|
|
|
|
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
|
|
|
|
log "fetching dotfiles"
|
|
$dotf fetch origin
|
|
$dotf checkout master
|
|
}
|
|
|
|
function do_salt_call(){
|
|
local salt="sudo salt-call --local --file-root $HOME/salt/states --pillar-root $HOME/salt/pillars"
|
|
new_log "Running salt high state"
|
|
if asktobreak;then
|
|
return
|
|
fi
|
|
$salt state.apply pillar="{username: $USER}"
|
|
}
|
|
|
|
function firefox_config(){
|
|
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
|
|
log "WARNING! all running firefox instances will be killed"
|
|
if asktobreak;then
|
|
return
|
|
fi
|
|
set +e
|
|
pkill -f firefox
|
|
set -e
|
|
$HOME/bin/install_firefox_addon
|
|
}
|
|
|
|
#initialize all options
|
|
ALL=true
|
|
FIREFOX=false
|
|
GNOME=false
|
|
SALT=false
|
|
DOTFILES=false
|
|
ANSWER_YES=false
|
|
while :; do
|
|
case $1 in
|
|
-h|-\?|--help)
|
|
printHelp
|
|
exit
|
|
;;
|
|
-f|--firefox)
|
|
FIREFOX=true
|
|
ALL=false
|
|
;;
|
|
-g|--gnome)
|
|
GNOME=true
|
|
ALL=false
|
|
;;
|
|
-s|--salt)
|
|
SALT=true
|
|
ALL=false
|
|
;;
|
|
-d|--dotfiles)
|
|
DOTFILES=true
|
|
ALL=false
|
|
;;
|
|
-y|--yes)
|
|
ANSWER_YES=true
|
|
;;
|
|
--) #End of all options
|
|
shift
|
|
break
|
|
;;
|
|
-?*)
|
|
printf "'$1' is not a valid option\n" >&2
|
|
exit 1
|
|
;;
|
|
*) #Break out of case, no more options
|
|
break
|
|
esac
|
|
shift
|
|
done
|
|
|
|
[[ $ALL == true ]] || [[ $DOTFILES == true ]] && setup_dotfiles
|
|
[[ $ALL == true ]] || [[ $SALT == true ]] && do_salt_call
|
|
[[ $ALL == true ]] || [[ $FIREFOX == true ]] && firefox_config
|
|
[[ $ALL == true ]] || [[ $GNOME == true ]] && gnome_config
|
|
|
|
printf "\n DONE!!!!!!!\n"
|