Skip to content

Commit

Permalink
Save answers in a setup.conf file so we don't need to prompt on every…
Browse files Browse the repository at this point in the history
… run
  • Loading branch information
tgm4883 committed Mar 14, 2019
1 parent 5c2a640 commit c02bbb6
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup.conf
90 changes: 78 additions & 12 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
LX_BASE=""
LX_VERSION=""

if [ -e setup.conf ]; then
echo "Saved configuration:"
cat ./setup.conf
echo ""
read -rp "Do you want to use this configuration? (type yes or no) " setupconfig;echo
if [ "$setupconfig" = "yes" ]; then
echo "Loading config from setup.conf"
. ./setup.conf
else
echo "Not loading setup.conf. Will prompt user."
fi
fi

if [ -r /etc/os-release ]; then
. /etc/os-release
if [ $ID = arch ]; then
Expand Down Expand Up @@ -37,7 +50,9 @@ for dir in $(ls root/); do cp -Rb root/$dir/* /$dir/; done
echo "Making /lib/systemd/system-sleep/sleep executable...\n"
chmod a+x /lib/systemd/system-sleep/sleep

read -rp "Do you want to replace suspend with hibernate? (type yes or no) " usehibernate;echo
if [ -z "${usehibernate}" ]; then
read -rp "Do you want to replace suspend with hibernate? (type yes or no) " usehibernate;echo
fi

if [ "$usehibernate" = "yes" ]; then
if [ "$LX_BASE" = "ubuntu" ] && [ 1 -eq "$(echo "${LX_VERSION} >= 17.10" | bc)" ]; then
Expand All @@ -51,7 +66,9 @@ else
echo "Not touching Suspend\n"
fi

read -rp "Do you want use the patched libwacom packages? (type yes or no) " uselibwacom;echo
if [ -z "${uselibwacom}" ]; then
read -rp "Do you want use the patched libwacom packages? (type yes or no) " uselibwacom;echo
fi

if [ "$uselibwacom" = "yes" ]; then
echo "Installing patched libwacom packages..."
Expand All @@ -61,7 +78,9 @@ else
echo "Not touching libwacom"
fi

read -rp "Do you want to remove the example intel xorg config? (type yes or no) " removexorg;echo
if [ -z "${removexorg}" ]; then
read -rp "Do you want to remove the example intel xorg config? (type yes or no) " removexorg;echo
fi

if [ "$removexorg" = "yes" ]; then
echo "Removing the example intel xorg config..."
Expand All @@ -70,7 +89,9 @@ else
echo "Not touching example intel xorg config (/etc/X11/xorg.conf.d/20-intel_example.conf)"
fi

read -rp "Do you want to remove the example pulse audio config files? (type yes or no) " removepulse;echo
if [ -z "${removepulse}" ]; then
read -rp "Do you want to remove the example pulse audio config files? (type yes or no) " removepulse;echo
fi

if [ "$removepulse" = "yes" ]; then
echo "Removing the example pulse audio config files..."
Expand Down Expand Up @@ -210,7 +231,9 @@ echo "Installing mwlwifi firmware...\n"
mkdir -p /lib/firmware/mwlwifi/
unzip -o firmware/mwlwifi_firmware.zip -d /lib/firmware/mwlwifi/

read -rp "Do you want to set your clock to local time instead of UTC? This fixes issues when dual booting with Windows. (type yes or no) " uselocaltime;echo
if [ -z "${uselocaltime}" ]; then
read -rp "Do you want to set your clock to local time instead of UTC? This fixes issues when dual booting with Windows. (type yes or no) " uselocaltime;echo
fi

if [ "$uselocaltime" = "yes" ]; then
echo "Setting clock to local time...\n"
Expand All @@ -221,21 +244,64 @@ else
echo "Not setting clock"
fi

read -rp "Do you want this script to download and install the latest kernel for you? (type yes or no) " autoinstallkernel;echo
if [ -z "${autoinstallkernel}" ]; then
read -rp "Do you want this script to download and install the latest kernel for you? (type yes or no) " autoinstallkernel;echo
fi

if [ "$autoinstallkernel" = "yes" ]; then
echo "Downloading latest kernel...\n"

urls=$(curl --silent "https://api.github.com/repos/jakeday/linux-surface/releases/latest" | grep '"browser_download_url":' | sed -E 's/.*"([^"]+)".*/\1/')
json=$(curl --silent "https://api.github.com/repos/jakeday/linux-surface/releases/latest")
if [ -e /usr/bin/jq ]
then
echo "Checking if the latest kernel version is already installed.\n"
LATESTKERNELVERSION=$(echo $json | jq .tag_name | cut -d '-' -f1 | tr -d '"')
LATESTKERNELVERSIONINSTALLED=$(dpkg -l | grep linux-image-$LATESTKERNELVERSION)
if [ $? = "0" ]; then
read -rp "Latest kernel version is already installed. Do you want to redownload and reinstall the latest kernel? (type yes or no) " INSTALLKERNEL;echo
else
echo "Latest kernel version is not installed, will download.\n"
INSTALLKERNEL='yes'
fi
else
INSTALLKERNEL="yes"
fi

if [ "$INSTALLKERNEL" = "yes" ]; then
echo "Downloading latest kernel...\n"

resp=$(wget -P tmp $urls)
urls=$(curl --silent "https://api.github.com/repos/jakeday/linux-surface/releases/latest" | grep '"browser_download_url":' | sed -E 's/.*"([^"]+)".*/\1/')

echo "Installing latest kernel...\n"
resp=$(wget -P tmp $urls)

dpkg -i tmp/*.deb
rm -rf tmp
echo "Installing latest kernel...\n"

dpkg -i tmp/*.deb
rm -rf tmp
else
echo "Latest kernel already installed, Not redownloading\n"
fi
else
echo "Not downloading latest kernel"
fi

if [ "$setupconfig" = "no" -o ! -e setup.conf ]; then
read -rp "Do you want to save your answers to setup.conf? (type yes or no) " saveconfig;echo
if [ "$saveconfig" = "yes" ]; then
echo "Saving answers to setup.conf\n"
#echo "copyroot=$copyroot" > setup.conf
#echo "sleepexecutable=$sleepexecutable" >> setup.conf
echo "usehibernate=$usehibernate" >> setup.conf
echo "uselibwacom=$uselibwacom" >> setup.conf
echo "removexorg=$removexorg" >> setup.conf
echo "removepulse=$removepulse" >> setup.conf
#echo "iptsfirmware=$iptsfirmware" >> setup.conf
#echo "marvellfirmware=$marvellfirmware" >> setup.conf
#echo "mwlwifi=$mwlwifi" >> setup.conf
echo "uselocaltime=$uselocaltime" >> setup.conf
echo "autoinstallkernel=$autoinstallkernel" >> setup.conf
else
echo "Not saving answers.\n"
fi
fi

echo "\nAll done! Please reboot."

0 comments on commit c02bbb6

Please sign in to comment.