After installing and reinstalling my personal desktop some zillion times over the past couple of decades, I have recently gotten tired of following and updating my notes, and taking days to get stuff set up. So, as part of the process of cleaning up my notes, I started thinking like the programmer I am and decided that "all this" could be scripted... not in the traditional scripted to the n'th degree in painfully difficult to read and maintain but awesomely efficient shell scripts way, but rather in the, I'd be able to run a script and get my stuff installed and configured automagically as much as possible and with minimal intervention. So, I've launched the plan and it's working out pretty well.
Here's what I done... First I created a directory structure for my work in ~/0wa/_CD_DVD/freebsd14 (where I put install stuff):
packages/
scripts/
scripts/post-install
logs
Then I created a 00-install-stuff.sh at the top level. This script sets up the install process and runs any scripts it finds in scripts, then it runs any scripts in scripts/post-install. It logs everything (tee and sh +x stuff to logs. So far, it's pretty extensible, I've only made super minor tweaks to the top level script and when I figure out a new thing to install and how it works, I just add a script in scripts. I'm not trying real hard to manage dependencies (but I do try to write scripts that don't depend on each other) but the poor man's dependency control is to name the scripts 01-whatever, 01-whatever-else, 02-something-else (depends on 01-whatever). Any files that need to be installed are put in packages.
A sample of files in packages:
mint-backgrounds.tar.gz
mysql-connector-j-8.0.33.jar
org.apache.commons.commons-codec_1.16.0.jar
org.jkiss.dbeaver.ext.generic_2.3.209.202402111410.jar
org.jkiss.dbeaver.slf4j_2.0.93.202402111410.jar
org.osgi.service.event_1.4.1.202109301733.jar
otf.zip
slf4j.api_2.0.9.jar
spain1.ovpn
A sample of files in scripts:
01-firefox-fonts.sh
01-fonts.sh
01-javadocs.sh
01-jdftweak.sh
01-jdiskreport.sh
01-latex.sh
01-mint-backgrounds.sh
01-mysql-connector.sh
01-nordvpn.sh
01-perl.sh
01-ruby.sh
Post-install stuff is like adding users and stuff.
Here's the 01-ruby.sh script to give you a feel for the scripts:
nevermind that sublime isn't ruby... it's cruft that I should clean up, but hey, it's a work in progress.
I also mirror the directory in test and that's where I try out new scripts.
Anyhow, I thought I'd be transparent and share to see if y'all are doing anything similar, but maybe better/easier. My objective isn't to perfect a script system, just to make it so I can simplify my build process. With the current setup, I can be back up and running from bare metal in about two hours, most of the time is waiting on the scripts. It used to be a couple of days of tweaking this setting, running that custom installer, copy this, copying that, etc.
Note: the scripts have some interactions cuz I'm not gonna spend the time to figure out how to do it without answering prompts unless the package provides --no-interaction type arguments that are easy to follow (an example is texlive - it's much faster to download the iso, save it into packages, and let the script mount it, install it, add environment variables, etc. than it is to do it via download, thankfully it has --no-interaction and reasonable arguments, otherwise, you'd have to run the tui/gui and they are decidedly not script friendly).
Cheers.
Here's what I done... First I created a directory structure for my work in ~/0wa/_CD_DVD/freebsd14 (where I put install stuff):
packages/
scripts/
scripts/post-install
logs
Then I created a 00-install-stuff.sh at the top level. This script sets up the install process and runs any scripts it finds in scripts, then it runs any scripts in scripts/post-install. It logs everything (tee and sh +x stuff to logs. So far, it's pretty extensible, I've only made super minor tweaks to the top level script and when I figure out a new thing to install and how it works, I just add a script in scripts. I'm not trying real hard to manage dependencies (but I do try to write scripts that don't depend on each other) but the poor man's dependency control is to name the scripts 01-whatever, 01-whatever-else, 02-something-else (depends on 01-whatever). Any files that need to be installed are put in packages.
A sample of files in packages:
mint-backgrounds.tar.gz
mysql-connector-j-8.0.33.jar
org.apache.commons.commons-codec_1.16.0.jar
org.jkiss.dbeaver.ext.generic_2.3.209.202402111410.jar
org.jkiss.dbeaver.slf4j_2.0.93.202402111410.jar
org.osgi.service.event_1.4.1.202109301733.jar
otf.zip
slf4j.api_2.0.9.jar
spain1.ovpn
A sample of files in scripts:
01-firefox-fonts.sh
01-fonts.sh
01-javadocs.sh
01-jdftweak.sh
01-jdiskreport.sh
01-latex.sh
01-mint-backgrounds.sh
01-mysql-connector.sh
01-nordvpn.sh
01-perl.sh
01-ruby.sh
Post-install stuff is like adding users and stuff.
Here's the 01-ruby.sh script to give you a feel for the scripts:
Code:
#!/usr/local/bin/bash -x
#********** ruby
pushd ~
rm -fr ~/.rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
# skip if ark restore
cat << "EOF" >> ~/.bashrc
export PATH=$HOME/.rbenv/bin:$PATH
eval "$(rbenv init -)"
EOF
export PATH=~/.rbenv/bin:$PATH
eval "$(rbenv init -)"
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-doctor | bash
MAKE=make rbenv install 3.3.0
rbenv global 3.3.0
gem update --system
gem install rubocop
echo "alias sl='/usr/local/bin/sublime'" >> ~/.bashrc
popd
nevermind that sublime isn't ruby... it's cruft that I should clean up, but hey, it's a work in progress.
I also mirror the directory in test and that's where I try out new scripts.
Anyhow, I thought I'd be transparent and share to see if y'all are doing anything similar, but maybe better/easier. My objective isn't to perfect a script system, just to make it so I can simplify my build process. With the current setup, I can be back up and running from bare metal in about two hours, most of the time is waiting on the scripts. It used to be a couple of days of tweaking this setting, running that custom installer, copy this, copying that, etc.
Note: the scripts have some interactions cuz I'm not gonna spend the time to figure out how to do it without answering prompts unless the package provides --no-interaction type arguments that are easy to follow (an example is texlive - it's much faster to download the iso, save it into packages, and let the script mount it, install it, add environment variables, etc. than it is to do it via download, thankfully it has --no-interaction and reasonable arguments, otherwise, you'd have to run the tui/gui and they are decidedly not script friendly).
Cheers.