SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-04-09 10:23:28

smacz
#! Junkie
Registered: 2014-12-09
Posts: 250

bunsen-dev.sh

I've scripted a program that downloads/installs/configures a vanilla Jessie install with the BunsenLabs Github repos and that can keep it up-to-date it as the repos are updated. The dependancies are loosely based on @johnraff's Wally (Cheat Sheet) Part 1, 3(a), and 4; but should work for most Jessie netinstalls with openbox.

This script can also be found at my github repo. I was motivated to do this because I like stress-testing new ideas and scripts that are put out. This will let me keep up-to-date with one simple command. Consult the README on github for usage and up-to-date bug tracking:

#!/bin/bash
#
### Use the BunsenLabs repos at github.com/bunsenlabs to configure the DE.
###### There's talk of Bunsen-Lite and Bunsen Standard. I call this Bunsen-Dev.
#
# Written by @smacz 2015/04/09
#
# License to follow -- Probably some GPL or something
#
# I chose to symlink everything here as this is just a testing setup. That way,
# as the programs get updated in the cloned repos, they will update in their
# appropriate places in the system as well. 
#
# This uses bashisms -- if this doesn't work on another shell, I can't be held
# accountable (mainly the question prompts). 
#
# dubug is built-in with (fun) echo statements (to be commented-out later)

repos="bunsen-configs bunsen-exit bunsen-pipemenus bunsen-user-setup
	bunsen-images bunsen-faenza-icon-theme bunsen-conky bunsen-welcome
	bunsen-common bunsen-lock bunsen-wmhacks deb8-theme bunsen1-dark-theme
	bunsen1-theme bunsen-docs bunsen-installscripts"

echo "-------------------------------------------------------"
echo "Do you want choose which repos to update?"
echo "-------------------------------------------------------"
echo "-- If you had modified any programs:  Select Yes ------"
echo "-------------------------------------------------------"
echo "-- If this is just an update: ------- Select No -------" 
echo "-------------------------------------------------------"
echo "-- If you have no repos yet: --------	Select Enter ----"
echo "-------------------------------------------------------"
echo "[Y]es | [N]o | Quit = (Ctrl-C)"
echo "-------------------------------------------------------"
read -p "Answer: " answer
case ${answer:0:1} in
	y|Y )
		gfetch=true
	;;
	n|N )
		gfetch=''
	;;
esac

# If there is no BunsenLabs main folder
if [ ! -d ~/BunsenLabs ]; then
	echo "Making ~/BunsenLabs"
    # make folder
    mkdir ~/BunsenLabs && cd ~/BunsenLabs
	# clone every repo into the ~/BunsenLabs dir
    for repo in $repos; do
		git clone https://github.com/bunsenlabs/$repo
	done
# If you're working on something and don't want to merge the latest commits
elif [ $gfetch ]; then
    for repo in $repos; do
		echo ''
		echo "Fetching latest commits for $repo but not merging yet."
		echo ''
		# 'git fetch' for every repo to store latest commit in .git/FETCH_HEAD
		cd ~/BunsenLabs/$repo
		git fetch https://github.com/bunsenlabs/$repo
		echo "-------------------------------------------------------"
		echo "Do you want to overwrite $repo with the latest github version?"
		echo "-------------------------------------------------------"
		echo "[Y]es | [N]o | Quit = (Ctrl-C)"
		echo "-------------------------------------------------------"
		read -p "Response: " response
		case ${response:0:1} in 
			y|Y )
				overwrite=true
			;;
			* )
				overwrite=false
			;;
		esac
		# if user wants to overwrite repo, merge the latest commit
		if [ $overwrite ]; then
			echo ''
			echo "overwriting $repo"
			echo ''
			git merge 
		else 
			echo ''
			echo "Execute 'git merge' at your convenience to bring the branch up-to-date"
			echo ''
		fi
    done   
	cd ~/BunsenLabs
else 
    # If user just wants to update all repos
    for repo in ~/BusenLabs $repos; do
		echo ''
		echo "Updating $repo..."
		echo ''
		# update each repo one at a time
		cd ~/BunsenLabs/$repo
		git pull https://github.com/bunsenlabs/$repo
    done   
    cd ~/BunsenLabs

fi

# Get a list of all of the executables that are in the BunsenLabs directory This
# is tricky because some of the folders are returned as executable, so to parse
# those out of the results, pass the `-not -type d` switch. Also, only return 
# the ones that are executable...I don't need to move all the `.png`'s to 
# '/usr/bin'!!!
execs=$(find ~/BunsenLabs -iname "bl-*" -executable -not -type d)

for executable in $execs; do
	# For each executable file, test to see if they don't already exist in
	# /usr/bin/ because if they don't, we need to create a symlink as this
	# indicates that a new executable has been added to the repos
	if [ ! -f /usr/bin/$(basename $executable) ]; then
		echo ''
		echo "$(basename $executable) was not in /usr/bin. Linking now..."
		echo ''
		sudo ln -s $executable /usr/bin/
	fi
done
# You may wish to update the autostart with any executables that are to initiate
# on login -- especially bl-hotcorners. If xscreensaver is in there but not on
# your system, I would suggest that be deleted as well.

#****** Subject to change, as @johnraff wants to rearrange the theme dir
#****** structure in the repos
# List all of the theme directories
themes="bunsen1-dark-theme bunsen1-theme deb8-theme"

for theme in $themes; do
	for file in $(find ~/BunsenLabs/$theme -type f); do
		echo ''
		echo "Looking for $(basename $file) in /usr/share/themes/$theme"
		echo ''
		# For each theme , test to see if a file withing doesn't already exist in
		# /usr/share/themes because if it doesn't, we need to create a symlink as
		# this indicates that a new theme has been added to the repos. Because
		# there is a directory hierarchy that has to be followed that is deeper
		# than two levels, the entire symlink for the theme will be erased if a
		# missing file is found. Otherwise the code gets messy. Use `-L` to
		# follow symlinks
	# recvd error -- too many arguments after full check was done? -type f
	# that solved a few. A few files with problems are:
		# still fails on bunsen1-theme && deb8 themes. IDK why
			# 'Looking for HEAD in /usr/share/themes/bunsen1-theme'
			# 'home/$USER/BunsenLabs/bunsen1-theme/.git/logs/refs/remotes/origin/HEAD
				# not found'
				# bunsen1-theme does not contain all of the up-to-date files:
				# Removing
				# Linking
		
			# looking for gtkrc in /usr/share/themes/deb8-theme
			# 'home/$USER/BunsenLabs/deb8-theme/xfce-notify-4.0/gtkrc not found'
				# deb8-theme does not contain all of the up-to-date files
				# Removing
				# Linking

		if [[ ! -f $(find -L /usr/share/themes/$theme -type f -name "$(basename $file)") ]]; then
			echo ''
			echo "$file not found."
			echo ''
			echo "$theme does not contain all of the up-to-date files:"
			echo ''
			if [ -d /usr/share/themes/$theme ]; then
				echo ''
				echo "Removing outdated $theme..."
				echo ''
				sudo rm -r /usr/share/themes/$theme
			fi
			echo ''
			echo "Linking updated $theme..."
			echo ''
			sudo ln -s ~/BunsenLabs/$theme /usr/share/themes/
			break
		else
			echo ''
			echo "Found."
			echo ''
		fi
	done
done

# Get all of the wallpaper files. These (currenly) are in subfolders, so the
# depth has to be two. To make sure that no directories are returned, specify
# the type of file 'f', which literally means file (aka not a directory)
wallpapers=$(find ~/BunsenLabs/bunsen-images/wallpapers -type f)

for wallpaper in $wallpapers; do
	# For each executable file, test to see if they don't already exist in
	# /usr/share/wallpapers because if they don't, we need to create a symlink
	# as this indicates that a new image has been added to the repos.
	if [ ! -f $(find -L /usr/share/wallpapers -name $(basename $wallpaper)) ]; then
		# I honestly can't believe that $(basename $(dirname $wallpaper))
		# works!!! It had to though in order to preserve the directory
		# structure, which, upon reflection, probably isn't that terribly
		# important, but the function is so interesting, that if no one minds,
		# I'm just going to keep in in there.
		echo ''
		echo "Found newly installed wallpaper $wallpaper. Linking..."
		echo ''
		sudo ln -s $wallpaper /usr/share/wallpapers/$(basename $(dirname $wallpaper))/
	fi
done

# Get all backgrounds for grub/LightDM and svg files (whatever those are)
backgrounds="svg bl-grub bl-login"

for background in $backgrounds; do
	for image in $(find ~/BunsenLabs/bunsen-images/$background -type f); do
		# For each image ,test to see if a file doesn't already exist 
		# in /usr/share/images/desktop-base because if it doesn't, we need to 
		# create a symlink as this indicates that a new theme has been added to 
		# the repos. Because there is a directory hierarchy that has to be 
		# followed that is deeper than two levels, the entire symlink for the 
		# background will be erased if a file is found to be missing. Otherwise 
		# the code gets messy.
		if [ ! -f $(find -L /usr/share/images/desktop-base -name $(basename $image)) ]; then
			echo ''
			echo "$background does not contain all of the up-to-date files:"
			echo ''
			# If the background directory exists, delete it.
			if [ -d /usr/share/images/desktop-base/$background ]; then
				echo ''
				echo "Removing outdated $background directory..."
				echo ''
				sudo rm -r /usr/share/images/desktop-base/$background
			fi
			# If it doesn't, it's safe to skip to this step. If it did exist,
			# it's already been deleted and now it will be re-linked.
			echo ''
			echo "Linking updated $background directory"
			echo ''
			sudo ln -s ~/BunsenLabs/$background /usr/share/images/desktop-base/
			break

		fi
	done
done

# Link all appropriate files to /usr/lib/bunsen
if [ ! -d /usr/lib/bunsen ]; then
	echo ''
	echo "/usr/lib/bunsen not found. Creating..."
	echo ''
	sudo mkdir /usr/lib/bunsen
fi
	# TODO: Link whatever else needs to be linked here
# Update the libs and force it, becuase there's no need to test when I'm not
# sure at the moment if I'm even hitting all of the necessary files anyways.
echo ''
echo "Linking appropriate folders to /usr/lib/bunsen"
echo ''
sudo ln -sfn ~/BunsenLabs/{bunsen-common,bunsen-welcome} /usr/lib/bunsen

###### Once (if) @woodape gets a pull request going for his `bl-*-switcher`s
###### (see below) I will suggest this be built into the file tree structure at 
###### github. For now though, this hack is necessary for it to work. Feel free
###### to comment this out if you don't intend on using `bl-*-switcher`. I
###### recommend that you give it a test-drive at least though.
echo ''
echo "Making '.config/' compatable with bl-*-switcher"
echo ''
if [ ! -d ~/BunsenLabs/bunsen-configs/.config/conky ]; then
	mkdir ~/BunsenLabs/bunsen-configs/.config/conky
fi
cp -r ~/BunsenLabs/bunsen-conky/* ~/BunsenLabs/bunsen-configs/.config/conky/

# Copy hidden configs to home directory. (the ones that have stuff in them
# anyways) All existing files and directories (such as .config, .conkyrc,
# gtkrc-2.0, etc) will all be overwritten with the `-f` flag for `ln`. 
configs=".config .conkyrc .gmrunrc .gtkrc-2.0 .gtkrc-2.0.mine .local .pbuilderrc .profile.bunsen .Xresources .xsessionrc"

for config in $configs; do
	if [ -d ~/$config ]; then
		echo ''
		echo "$config is a directory -- removing so 'ln' can work"
		echo ''
		rm -r ~/$config
	fi
	echo ''
	echo "Linking $config to home dir..."
	echo ''
	sudo ln -sf ~/BunsenLabs/bunsen-configs/$config ~/
done

# Link all documentation to the /usr/share/doc directory. I have to say, I am
# not at *all* sure that this is correct, either in implmentation or intention.
# If someone has a better idea than do I, please speak up.
dirs=$(find ~/BunsenLabs/* -maxdepth 1 -type d)

for dir in $dirs; do
	# Should this be in /usr/lib/bunsen instead???
	if [ ! -d /usr/share/doc/$(basename $dir) ]; then
		echo ''
		echo "No directory found named $(basename $dir). mkdir-ing..."
		echo ''
		sudo mkdir /usr/share/doc/$(basename $dir)
	fi
	echo ''
	echo "Linking what I believe to be the appropriate docs to $(basename $dir)"
	echo ''
	sudo ln -sfn $dir/debian/ $dir/READM* $dir/LICENS* /usr/share/doc/$(basename $dir)
done

### EXTRA EXTRA EXTRA!!! READ ALL ABOUT IT!!! 
# Here are a couple tidbits that I feel could spruce up the place a bit. Read on
# and uncomment to enjoy.

# The Conky and Tint2 switchers make it easy to start and stop or just flat out
# replace the running instances with one of you (many?) configs. This is great
# for demoing how "cool" linux is to the ladies.
#git clone git://github.com/woodape/bl-switcher
# Read the README to figure out how to insert these into the openbox root menu
#sudo ln -s ~/BunsenLabs/bl-switccher/bl-* /usr/bin
# Update autostart file

# Bunsen (may) not have an official battery applett on the tint2 taskbar for the
# time being. Right now, I think that tidybattery works just fine, especially
# since @nicholasalipaz had tweaked it per the discussion on the forums.
#git clone git://github.com/decayofmind/tidybattery
#sudo ln -s ~/BunsenLabs/tidybattery/tidybattery.py /usr/bin/tidybattery
# Create config file from README
#echo -e "$(copy-of-the-command-that's-in-the-README-so-you-better-read-it)"
# Update autostart file

clear
echo "Configuration complete." 
echo ''
echo "Note that the autostart file was not updated. If
there have been changes, or if this is the first install, you may wish to make
sure that your favorite program is in that file if you don't see it after
rebooting." 
echo ""
echo "If this is your first run, I would suggest rebooting now."
echo ""
echo "Otherwise, send me a PM or post on the #! forums about whatever bug you just found"
echo ""
echo "TODO:"
echo "Icons -- Untarring and to /usr/share/icons"
echo "Theme bug -- constant linkage of deb8-theme and bunsen1-theme"
echo "Theme GRUB && LightDM"
echo "bl-welcome dependencies"
echo "Select Enter"
echo "Initial sudo"

NOTE: Several bugs already exist for either feature requests or questionable code at the time of release. However, the code above works. I would advise that you run this in nothing more critical than a VM or test install. Once again, please see the README linked above for updated information.

Last edited by smacz (2015-04-10 02:15:14)

Offline

Be excellent to each other!

#2 2015-04-09 15:12:01

nicholasalipaz
#! Member
Registered: 2015-02-05
Posts: 72

Re: bunsen-dev.sh

Nice script and thanks for the mention on tidybattery!

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo