-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·120 lines (107 loc) · 2.96 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·120 lines (107 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
#
# Script for setting up the contents of the .local tree into a linux userspace.
# (backs up and existing files when found)
#
now=$(date +"%Y-%m-%d_%H-%M-%S")
my_home="${HOME}"
home_python_req="${my_home}/.local/requirements.txt"
cd "${my_home}"
# Helper function "installing" a link in the home directory
#
# Usage:
# backup_and_link <source> <target>
#
# Where "source" is a file in the $HOME/.local/etc/linux-home/ directory and
# "target" is the target file to be placed in the $HOME directory.
#
function backup_and_link() {
# Bad stuff happens if $1 or $2 are empty
if [ -z "$1" ]
then
echo "ERROR: Source file name missing"
return -1
fi
if [ -z "$2" ]
then
echo "ERROR: Target filename missing"
return -1
fi
source=".local/etc/linux-home/$1"
target="${my_home}/$2"
echo "${target} -> ${source}"
# echo "Linking ${target} -> ${source}"
# Check if the target is currently a link and is referencing the given
# source.
if [ -L "${target}" -a "$(readlink ${target})" = "${source}" ]
then
echo "-- Link already exists"
else
# If the target already exists as a file or directory, back it up.
if [ -f "${target}" -o -d "${target}" ]
then
backup_target="${target}.${now}"
echo "-- Backing up existing file: ${target} -> ${backup_target}"
mv "${target}" "${backup_target}"
fi
echo "-- Linking"
ln -s "${source}" "${target}"
fi
}
#
# Link pertinent files in the ${my_home} directory.
#
backup_and_link bashrc .bashrc
backup_and_link inputrc .inputrc
backup_and_link bash_aliases .bash_aliases
backup_and_link bash_profile .bash_profile
backup_and_link bash_logout .bash_logout
backup_and_link emacs .emacs
backup_and_link gitconfig .gitconfig
backup_and_link gitignore.global .gitignore.global
backup_and_link tmux.conf .tmux.conf
backup_and_link tmux .tmux
backup_and_link vimrc .vimrc
backup_and_link vim .vim
#
# Vundle install
#
vim +PluginInstall +qall
#
# Install user-space python packages
#
# When expanding beyond Ubuntu/Fedora, check on the assumption of package
# naming formats across platforms that use the same package management tool.
# I.e. Maybe Debian packages are named different than Ubuntu, etc., in such a
# way that grouping installation logic by package management tool is actually
# invalid.
#
>&2 echo "Installing required system packages"
OS_TAG="$(lsb_release -si 2>/dev/null)"
USES_APT=( "Ubuntu" )
USES_DNF=( "Fedora" )
if [[ " ${USES_apt} " =~ [[:space:]]"${OS_TAG}"[[:space:]] ]]
then
sudo apt install \
pipx \
python3-virtualenv \
python3-virtualenvwrapper
elif [[ " ${USES_DNF} " =~ [[:space:]]"${OS_TAG}"[[:space:]] ]]
then
sudo dnf install \
pipx \
python3-virtualenv \
python3-virtualenvwrapper
else
echo "No installation instructions for basic installs on platform:"
lsb_release -a
exit 1
fi
#
# PipX Install things
#
pipx install ansible-core
pipx install git-filter-repo
pipx install magic-wormhole
pipx install poetry
pipx install uv