Skip to content

Commit

Permalink
Apps (#1)
Browse files Browse the repository at this point in the history
* adding apps for stowit

* adding extensions install

* adding gnome extensions, updating dep packages

* lint

* linting

* bump dot version to 0.2, adding dotfiles + stowit.sh, adding post-initial.sh

* updating README.md
  • Loading branch information
eddinn committed Oct 23, 2019
1 parent aea2fd9 commit 04a7298
Show file tree
Hide file tree
Showing 19 changed files with 772 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
.git
Dockerfile*
3 changes: 0 additions & 3 deletions Dockerfile.fedora

This file was deleted.

4 changes: 0 additions & 4 deletions Dockerfile.ubuntu

This file was deleted.

58 changes: 56 additions & 2 deletions README.md
@@ -1,2 +1,56 @@
# initial-package-install
Script that installs the selective user packages for Ubuntu/Fedora
# Initial-package-install

Scripts that installs selective base user packages and extensions for initial setup of users workspase in Ubuntu/Fedora.

---

## Files TOC

1. Root:
./initial-package-install.sh
./post-initial.sh
2. Extensions dir:
./ext/
./ext/gnome-ext.sh
./ext/vscode-ext.sh
3. Applications dir:
./apps/
./apps/pip.sh
./apps/snap.sh
4. Dotfiles dir:
./dots/
./dots/bash/.profile
./dots/bash/.bashrc
./dots/bin/
./dots/bin/bin/
./dots/bin/bin/apt-cleanup.sh
./dots/bin/bin/remove-old-snaps.sh
.dots/git/.gitconfig
.dots/LICENSE
.dots/README.md
.dots/stowit.sh
.dots/zsh/.zshrc

### Basic usage

#### If `git` is installed on the system

```bash
git clone https://github.com/eddinn/initial-package-install.git
cd ./initial-package-install
bash ./initial-package-install.sh && bash ./post-initial.sh
```

#### If `git` is not already installed on the system

```bash
# Try curl, else fall back to wget
curl -L -O https://raw.githubusercontent.com/eddinn/initial-package-install/master/initial-package-install.sh || wget -L -O https://raw.githubusercontent.com/eddinn/initial-package-install/master/initial-package-install.sh
bash ./initial-package-install.sh

# Now we have git, so lets clone the repo and finish the setup
rm -Rf ./initial-package-install.sh
git clone https://github.com/eddinn/initial-package-install.git
cd ./initial-package-install
bash ./post-initial.sh
```
19 changes: 19 additions & 0 deletions apps/pip.sh
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Define Python3 Pip packages to install
pip_packages=(
setuptools
wheel
ansible
ansible-lint
ansible-tower-cli
pywinrm
testresources
)

# Install Python3 pip packages
echo -e '\nUpgrading pip and installing Python3 packages'
# First, upgrade pip to latest version
sudo -H pip install pip --upgrade
# Install packages to user space
pip3 install --user "${pip_packages[@]}"
19 changes: 19 additions & 0 deletions apps/snap.sh
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Define Snap packages to install
snap_packages=(
discord
gitkraken
spotify
)

# Install user snap packages
echo -e '\nInstalling VSCode and Slack with --classic'
sudo snap install code --classic
sudo snap install slack --classic
echo -e '\nInstalling Snap packages'
# Install the rest of the snap packages
for snaps in "${snap_packages[@]}";
do
sudo snap install "$snaps";
done
21 changes: 21 additions & 0 deletions dots/LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Edvin Dunaway

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
128 changes: 128 additions & 0 deletions dots/README.md
@@ -0,0 +1,128 @@
# dotfiles

## How to manage dotfiles with GNU stow

### Installation, setup and usage

A set of simple instructions to help you get started
Now let’s create a folder to get started. You can manage your dotfiles repo anywhere. I keep it along side my other code in `~/Prog/dotfiles.` So from here on, I will just refer to it as `$DOT`.

**Clone the dotfiles git repo, export the path and ```cd``` into it:**

```bash
# Create the dir structure you want, or cd into your current project folder
cd ~/Prog
git clone git@github.com:eddinn/dotfiles.git
export DOT=$HOME/Prog/dotfiles
cd $DOT
```

**Remember to replace or modify the dotfiles to your needs:**

```bash
mv ~/.zshrc $DOT/zsh
mv ~/.gitconfig $DOT/git
mv ~/.bashrc $DOT/bash
# You can also move .bash_profile and .profile if you have them
mv ~/.bash_profile $DOT/bash
mv ~/.profile $DOT/bash
```

**Example usage of the `stow` command:**

```bash
stow -v -R -t ~ git
# Output
LINK: .gitconfig => code/dotfiles/git/.gitconfig
ls -latr ~ | grep .git
# Output
lrwxrwxrwx 1 USER USER 28 jun 21 16:55 .gitconfig -> Prog/dotfiles/git/.gitconfig
```

`-v` is verbose, `-R` is recursive, and `-t ~` is the target directory, e.g your Home (`$HOME`) directory.

### The `stowit.sh` script

**Here are the contents of the ```stowit.sh``` script:**

```bash
#!/usr/bin/env bash
# Make sure we have pulled in and updated any submodules
git submodule init
git submodule update
# What directories should be installable by all users including the root user
base=(
bash
)
# Folders that should, or only need to be installed for a local user
useronly=(
git
)
# Run the stow command for the passed in directory ($2) in location $1
stowit() {
usr=$1
app=$2
# -v verbose
# -R recursive
# -t target
stow -v -R -t ${usr} ${app}
}
echo -e 'Stowing apps for user: ' "${whoami}"
# Install apps available to local users and root
for app in ${base[@]}; do
stowit "${HOME}" $app
done
# Install only user space folders
for app in ${useronly[@]}; do
if [[! "$(whoami)" = *"root"*]]; then
stowit "${HOME}" $app
fi
done
echo -e '\nAll done!'
```

As you can see, it's relatively straight forward and simple to use..
In the code above, we will install the git directory for only the local user as root doesn’t need that. However bash which we will do next, can be used for both local users and root. We then create a bash function named stowit to run the actual stow command with our required arguments.
The first loop is to install folders for any user, and the second has a check to install for any user unless it is the root user. So lets setup the bash directory.

**So lets run it to install our dotfiles:**

```bash
# Make the stowit.sh file executable
chmod a+x stowit.sh
# Run stowit.sh
./stowit.sh
# Output
Stowing apps for user:
LINK: .profile => Prog/dotfiles/bash/.profile
LINK: .bashrc => Prog/dotfiles/bash/.bashrc
LINK: .gitconfig => Prog/dotfiles/git/.gitconfig
LINK: .zshrc => Prog/dotfiles/zsh/.zshrc

All done!
```

You can see that stow is pretty smart about linking our files and folders. It linked our new bash files. But when we ran stow again it went through our previously linked git files, re re-linked them. You can actually configure how that handles those situations with different flags. stow will also abort stowing folders when it finds new files that have not been stowed before and will tell you what files so you can fix them.
To install the files for root, simply use ```sudo```

```bash
sudo ./stowit.sh
```

**The `bin` directory**

Inside the `$DOT/bin/bin` folder we can place any binary files and scripts we want to keep around for our system.

**Add export path to `.zshrc` or `.bashrc`:**

```bash
# Example with .zshrc
vim ~/.zshrc
export PATH="$HOME/bin:$PATH"
source ~/.zshrc
# Lets check and verify our path
echo $PATH
/home/USER/bin:/home/USER/.local/bin:/home/USER/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
```

We now have `/home/USER/bin` in our path where we can use to store all our scripts and files that we need to run in our environment as an alternative to `/usr/local/bin`.
120 changes: 120 additions & 0 deletions dots/bash/.bashrc
@@ -0,0 +1,120 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi

export PATH="$HOME/bin:$PATH"
export PATH=~/.npm-global/bin:$PATH

0 comments on commit 04a7298

Please sign in to comment.