Skip to content

Commit

Permalink
Update and add more files
Browse files Browse the repository at this point in the history
  • Loading branch information
royarg02 committed Jan 11, 2021
1 parent ee5a6d2 commit 7164f1e
Show file tree
Hide file tree
Showing 16 changed files with 778 additions and 41 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Anurag Roy

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.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# user_files

Contains some (mainly dotfiles) files to be deployed on a fresh linux system.

Intended to go along with [manjaro_init](https://github.com/RoyARG02/manjaro-init).

The files to be deployed are present in `files` folder.

The name of the files, alongwith the location to be deployed (_read copied_) to and the new name are maintained in `deploy_files.txt`. Additional comments are mentioned in that file about its usage.

The **POSIX** compliant main script, `deploy_user_files.sh`, reads the file list from `deploy_files.txt`, and copies them according to the instructions.
Executing the default instructions **will require superuser privileges**.

## Usage

1. Clone the repository.
2. Run `chmod +x deploy_user_files.sh`.
3. Run `sudo ./deploy_user_files.sh`.
48 changes: 28 additions & 20 deletions deploy_files.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
### The list of files and the locations they should be
### copied to.
### The list of files and the locations they should be copied to.
###
### The files are listed in this order:
### Each line below specifies the files to be copied by this order:
###
### <name of the file in this folder> <name to be copied as> <location to be copied to>
### <name of the file in "./files" folder> <name to be copied as> <location to be copied to>
###
### For instance, ".bashrc" for the root user is defined below as:
###
### <.rootbashrc> <.bashrc> </root>
### .rootbashrc .bashrc /root
###
### "Name to be copied as" can be omitted. In that case,
### the name of the file in this folder is used. See the
### line to copy ".bashrc" file for an example.
### "Name to be copied as" can be omitted. In that case, the same name of the
### file as it is named in the "./files" folder is used. See the line to copy
### ".bashrc" file for an example.
###
### Multiple locations can be defined for the file to be
### copied to multiple locations with the same name. If
### different file names are required, define them in
### separate lines.
### If any file is to be copied to multiple locations, name them one after the
### other at the end of the line. The file will be copied to those locations
### having the SAME name, so if different file names are desired, specify them
### in different lines.
###
### It's preferable to define the location of the file as
### an absolute path.
### It is preferable to define the location of the file as an absolute path,
### but "~" can be used to represent the user home directory.
###
### Copying any file in this list can be skipped by
### appending a '#' in front of the line, or by deleting
### them altogether.
### Copying any file in this list can be skipped by appending a '#' in front of
### the line, or by deleting them altogether.

.bashrc ~/
.bashrc ~
.rootbashrc .bashrc /root
.profile ~/
.vimrc ~/ /root
.rootprofile .profile /root
.profile ~
.vimrc ~ /root
.xinitrc ~ /root
.xprofile ~ /root
motd.sh /etc/profile.d
tlp.conf /etc
pacman.conf /etc
fstab /etc
inputrc /etc
optimus-manager.conf /etc/optimus-manager
nobeep.conf /etc/modprobe.d

44 changes: 37 additions & 7 deletions deploy_user_files.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
#!/usr/bin/sh

### Copies a list of files, from `deploy_files.txt`, to their
### appropriate locations.
### Copies a list of files, from `deploy_files.txt`, to their appropriate
### locations.
###
### See `deploy_files.txt` to see what files are being copied.
###
### Requires root permissions to function properly.

[ $(id -u) -ne 0 ] && \
### The location of the user home directory.
###
### This is used to substitute the "~" character in the locations specified in
### "deploy_files.txt"
USER_HOME="/home/anurag"

[ "$(id -u)" -ne 0 ] && \
echo "[ERROR] Copying user files needs root privileges to function properly" && exit 1

[ -r ./deploy_files.txt ] || \
echo "[ERROR] Could not find "deploy_files.txt". Are you sure it exists?" && exit 1
## Check if 'deploy_files.txt' exists and is readable
[ ! -r ./deploy_files.txt ] && \
echo "[ERROR] Could not find \"deploy_files.txt\". Are you sure it exists?" && exit 1

## Read list of files.

## If the file mentioned at the 2nd field exists and is a directory, assume
## that as a location.

### Since the script is run with elevated privileges, "~" will refer to "/root"
### instead of the user's home directory. The "sub" function of awk replaces
### the "~" character and with USER_HOME.
awk -v home=$USER_HOME '
! /^#.*$|^$/ {
copy_from=3;
copy_as="";
if(system("test -d "$2) == 0) {
copy_from=2;
} else {
copy_as=$2;
}
for( i=copy_from ; i <= NF ; ++i ){
sub(/^~/, home, $i);
system("cp -iv ./files/"$1" "$i"/"copy_as);
}
}' deploy_files.txt

## Read list of files
## TODO
unset USER_HOME
exit 0
2 changes: 1 addition & 1 deletion files/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fi
unset use_color use_256_color safe_term match_lhs sh PS1_not_256 PS1_256 PS1_no_color

## Aliases
alias ls='ls --color=auto'
alias ls='ls -N --color=auto'
alias grep='grep --colour=auto'
alias egrep='egrep --colour=auto'
alias fgrep='fgrep --colour=auto'
Expand Down
4 changes: 3 additions & 1 deletion files/.profile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export CHROME_EXECUTABLE="/usr/bin/chromium"
## shell experience
export HISTSIZE= ## infinite history
export HISTFILESIZE= ## infinite history
export HISTCONTROL=ignoredups
export HISTCONTROL=ignoredups:erasedups
export LESSHISTFILE=- ## do not create .lesshst file
export PROMPT_COMMAND='history -a' ## Enable history append at every command


## other program settings
export LESS_TERMCAP_mb=$'\e[01;31m'
Expand Down
12 changes: 6 additions & 6 deletions files/.rootbashrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
[[ $- != *i* ]] && return

## Source bash_completion if it exists and is readable
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
[[ -r /usr/share/bash-completion/bash_completion ]] && . /usr/share/bash-completion/bash_completion

# source git completion if it exists and is readable
[ -r /home/anurag/.git-completion.bash ] && . /home/anurag/.git-completion.bash
[[ -r /home/anurag/.git-completion.bash ]] && . /home/anurag/.git-completion.bash

# source git prompt if it exists and is readable
[ -r /home/anurag/.git-prompt.sh ] && . /home/anurag/.git-prompt.sh
[[ -r /home/anurag/.git-prompt.sh ]] && . /home/anurag/.git-prompt.sh

## Bash won't get SIGWINCH if another process is in the foreground.
## Enable checkwinsize so that bash will check the terminal size when
Expand All @@ -36,7 +36,7 @@ stty -ixon
## globbing instead of external grep binary.

# sanitize TERM
safe_term=${TERM//[^[:alnum:]]/?}
safe_term=${TERM//[^[:alnum:]]/?}

# check if TERM supports color
match_lhs=""
Expand Down Expand Up @@ -85,7 +85,7 @@ fi
unset use_color use_256_color safe_term match_lhs sh PS1_not_256 PS1_256 PS1_no_color

## Aliases
alias ls='ls --color=auto'
alias ls='ls -N --color=auto'
alias grep='grep --colour=auto'
alias egrep='egrep --colour=auto'
alias fgrep='fgrep --colour=auto'
Expand All @@ -103,7 +103,7 @@ alias mkdir='mkdir -pv'

## archive extractor
ex() {
if [ -f $1 ] ; then
if [[ -f $1 ]] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
Expand Down
5 changes: 4 additions & 1 deletion files/.rootprofile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#~/.profile

export EDITOR="vim"
export BROWSER="firefox"
export QT_QPA_PLATFORMTHEME="qt5ct"
Expand All @@ -10,8 +12,9 @@ export CHROME_EXECUTABLE="/usr/bin/chromium"
## shell experience
export HISTSIZE= ## infinite history
export HISTFILESIZE= ## infinite history
export HISTCONTROL=ignoredups
export HISTCONTROL=ignoredups:erasedups
export LESSHISTFILE=- ## do not create .lesshst file
export PROMPT_COMMAND='history -a' ## Enable history append at every command

## other program settings
export LESS_TERMCAP_mb=$'\e[01;31m'
Expand Down
8 changes: 3 additions & 5 deletions files/.xinitrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ if [ -d /etc/X11/xinit/xinitrc.d ] ; then
unset f
fi

# start gnome-keyring daemon
eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
export SSH_AUTH_SOCK
# source .xprofile
[ -f "~/.xprofile" ] && . ~/.xprofile

# start window manager
startxfce4
ssh-agent startxfce4
15 changes: 15 additions & 0 deletions files/fstab
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=33FD-E4AE /boot/efi vfat umask=0077 0 2
UUID=f70f70ea-d78b-40b8-9cf5-d3490c2218d0 / ext4 defaults,noatime 0 1
UUID=44065268-860e-4a75-8efa-41e833b34d32 /home ext4 defaults,noatime 0 2
UUID=3de38af1-fc89-4336-865b-c1340800f373 none swap defaults 0 0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
UUID=1893BD5B741FC612 /mnt/D ntfs defaults 0 0
UUID=4888CDE031BF1FFA /mnt/E ntfs defaults 0 0
UUID=49D007D2239C4886 /mnt/F ntfs defaults 0 0
37 changes: 37 additions & 0 deletions files/inputrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# do not bell on tab-completion
#set bell-style none

set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
set completion-ignore-case on

$if mode=emacs

# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[7~": beginning-of-line
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word

# for rxvt
"\e[8~": end-of-line

# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif
5 changes: 5 additions & 0 deletions files/motd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

curr_batt_percent=$(< /sys/class/power_supply/BAT0/capacity)
echo "The current battery charge is at $curr_batt_percent%."

3 changes: 3 additions & 0 deletions files/nobeep.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Do not load the 'pcspkr' module on boot.
blacklist pcspkr

24 changes: 24 additions & 0 deletions files/optimus-manager.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[intel]
DRI=3
accel=
driver=modesetting
modeset=yes
tearfree=

[nvidia]
DPI=96
PAT=yes
allow_external_gpus=no
ignore_abi=no
modeset=yes
options=overclocking

[optimus]
auto_logout=no
pci_power_control=yes
pci_remove=no
pci_reset=no
startup_auto_battery_mode=intel
startup_auto_extpower_mode=nvidia
startup_mode=intel
switching=nouveau
Loading

0 comments on commit 7164f1e

Please sign in to comment.