Advertisement
Guest User

Untitled

a guest
Apr 15th, 2019
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.10 KB | None | 0 0
  1. #!/bin/bash
  2. faf_sh_version=2.3
  3.  
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  16.  
  17. real_user=$(du /home 2>/dev/null | sort -n -r | head -n 2 | tail -n +2 | cut -d/ -f3)
  18. user_path="/home/"$real_user
  19. cd $user_path
  20.  
  21. echo "_______________________________________________________________________________________________________" >> $user_path/faf.sh-$faf_sh_version.log
  22. echo "-------------------------------------------------------------------------------------------------------" >> $user_path/faf.sh-$faf_sh_version.log
  23. # DETERMINE OS BASE :
  24. unameOut="$(uname -s)"
  25. case "${unameOut}" in
  26. Linux*)
  27. echo "[$(date --rfc-3339=seconds)] T1 New log file. fafSTACK version "$faf_sh_version" running : "$unameOut >> $user_path/faf.sh-$faf_sh_version.log;;
  28. Darwin*)
  29. echo "Mac / Apple Macintosh is not supported yet though it could technically be; as evidenced by previous examples of people running FA and even FAF on mac. Feel free to contribute at : https://github.com/tatsujb/installFAFscript"
  30. echo "[$(date --rfc-3339=seconds)] T1 New log file. fafSTACK version "$faf_sh_version". FAILIURE. MAC UNSUPPORTED. "$unameOut >> $user_path/faf.sh-$faf_sh_version.log
  31. exit 1;;
  32. CYGWIN*)
  33. echo "Hello, you can go straight to : www.faforever.com and click on \"Download Client\". This script exists in order to help linux users achieve the same thing you can do out-of-the-box on your operating system. You have not the remotest use for this script :) be free, wild bird!"
  34. echo "[$(date --rfc-3339=seconds)] T1 New log file. fafSTACK version "$faf_sh_version". FAILIURE. WINDOWS UNSUPPORTED. "$unameOut >> $user_path/faf.sh-$faf_sh_version.log
  35. exit 1;;
  36. MINGW*)
  37. echo "Hello, are can on MinGW you cannot run Forged Alliance, this script is of no use to you."
  38. echo "[$(date --rfc-3339=seconds)] T1 New log file. fafSTACK version "$faf_sh_version". FAILIURE. MINGW UNSUPPORTED. "$unameOut >> $user_path/faf.sh-$faf_sh_version.log
  39. exit 1
  40. esac
  41.  
  42.  
  43. function install_basics_function
  44. {
  45. if [ "$operating_system" = "Debian GNU/Linux" ];
  46. then
  47. apt install whiptail procps zenity -y; # here, in debian, user is already supposed to be running script as root. suggestions welcome
  48. else
  49. sudo echo "[$(date --rfc-3339=seconds)] sudo priveledges entrusted to script" >> ~/'faf.sh-'$faf_sh_version'.log' # suggestions welcome regarding entrusting sudo to a script
  50. sudo apt install whiptail procps zenity -y;
  51. fi;
  52. }
  53.  
  54. # DETERMINE LINUX DISTRO AND RELEASE :
  55. if [ -f /etc/os-release ]; then
  56. # freedesktop.org and systemd (Ubuntu 18.04+)
  57. . /etc/os-release
  58. operating_system=$NAME
  59. os_version=$VERSION_ID
  60. is_plasma="$(echo $XDG_DATA_DIRS | grep -Eo 'plasma')"
  61. if [ \( "$is_plasma" == "plasma" \) -o \( "$VERSION_ID" == "Ubuntu" \) ]
  62. then
  63. operating_system=Kubuntu
  64. fi
  65. if [ -z "$os_version" ]
  66. then
  67. os_version=$(lsb_release -sr)
  68. fi
  69. install_basics_function
  70. elif type lsb_release >/dev/null 2>&1; then
  71. # linuxbase.org (older Debian / Ubuntu should be here)
  72. operating_system=$(lsb_release -si)
  73. os_version=$(lsb_release -sr)
  74. install_basics_function
  75. if (whiptail --title "Distribution may be a little old ('$os_version') and is, at present, untested, Abort?" --yesno "Pursuing means you believe you know what you are doing and have pre-emptively read the contents of this .sh and are endowed with the needed skill to repair your OS, should things go wrong.\n\n Abort? \"Yes\" will stop the scipt, \"No\" will pursue" 10 100)
  76. then
  77. echo "You're probably right to choose this..."
  78. echo "exiting upon demand..."
  79. echo "[$(date --rfc-3339=seconds)] T1 Abandoned on user demand, OS version too experimental" >> $user_path/faf.sh-$faf_sh_version.log
  80. exit 1
  81. else
  82. echo "OK! fingers crossed!"
  83. echo "continuing..."
  84. echo "[$(date --rfc-3339=seconds)] T1 wrong distribution, user-chosen continue." >> $user_path/faf.sh-$faf_sh_version.log
  85. fi
  86. elif [ -f /etc/lsb-release ]; then
  87. # For some versions of Debian/Ubuntu without lsb_release command
  88. . /etc/lsb-release
  89. operating_system=$DISTRIB_ID
  90. os_version=$DISTRIB_RELEASE
  91. install_basics_function
  92. if (whiptail --title "Distribution $operating_system $os_version is at present untested, Abort?" --yesno "Pursuing means you believe you know what you are doing and have pre-emptively read the contents of this .sh and are endowed with the needed skill to repair your OS, should things go wrong.\n\n Abort? \"Yes\" will stop the scipt, \"No\" will pursue" 10 100)
  93. then
  94. echo "You're probably right to choose this..."
  95. echo "exiting upon demand..."
  96. echo "[$(date --rfc-3339=seconds)] T1 Abandoned on user demand, OS version too experimental" >> $user_path/faf.sh-$faf_sh_version.log
  97. exit 1
  98. else
  99. echo "OK! fingers crossed!"
  100. echo "continuing..."
  101. echo "[$(date --rfc-3339=seconds)] T1 wrong distribution, user-chosen continue." >> $user_path/faf.sh-$faf_sh_version.log
  102. fi
  103. elif [ -f /etc/debian_version ]; then
  104. # Older Debian/Ubuntu/etc.
  105. operating_system=oldDebian
  106. os_version=$(cat /etc/debian_version)
  107. install_basics_function
  108. if (whiptail --title "Distribution $operating_system $os_version is at present untested, Abort?" --yesno "Pursuing means you believe you know what you are doing and have pre-emptively read the contents of this .sh and are endowed with the needed skill to repair your OS, should things go wrong.\n\n Abort? \"Yes\" will stop the scipt, \"No\" will pursue" 10 100)
  109. then
  110. echo "You're probably right to choose this..."
  111. echo "exiting upon demand..."
  112. echo "[$(date --rfc-3339=seconds)] T1 Abandoned on user demand, OS version too experimental" >> $user_path/faf.sh-$faf_sh_version.log
  113. exit 1
  114. else
  115. echo "OK! fingers crossed!"
  116. echo "continuing..."
  117. echo "[$(date --rfc-3339=seconds)] T1 wrong distribution, user-chosen continue." >> $user_path/faf.sh-$faf_sh_version.log
  118. fi
  119. elif [ -f /etc/SuSe-release ]; then
  120. # Older SuSE/etc.
  121. operating_system=OpenSuSE
  122. os_version="unknown version but likely very old"
  123. install_basics_function
  124. if (whiptail --title "Distribution $operating_system $os_version is at present untested, Abort?" --yesno "Pursuing means you believe you know what you are doing and have pre-emptively read the contents of this .sh and are endowed with the needed skill to repair your OS, should things go wrong.\n\n Abort? \"Yes\" will stop the scipt, \"No\" will pursue" 10 100)
  125. then
  126. echo "You're probably right to choose this..."
  127. echo "exiting upon demand..."
  128. echo "[$(date --rfc-3339=seconds)] T1 Abandoned on user demand, OS version too experimental" >> $user_path/faf.sh-$faf_sh_version.log
  129. exit 1
  130. else
  131. echo "OK! fingers crossed!"
  132. echo "continuing..."
  133. echo "[$(date --rfc-3339=seconds)] T1 wrong distribution, user-chosen continue." >> $user_path/faf.sh-$faf_sh_version.log
  134. fi
  135. elif [ -f /etc/redhat-release ]; then
  136. # Older Red Hat, CentOS, etc.
  137. operating_system=oldRedHatorCentos
  138. os_version="unknown version but likely very old"
  139. install_basics_function
  140. if (whiptail --title "Distribution $operating_system $os_version is at present untested, Abort?" --yesno "Pursuing means you believe you know what you are doing and have pre-emptively read the contents of this .sh and are endowed with the needed skill to repair your OS, should things go wrong.\n\n Abort? \"Yes\" will stop the scipt, \"No\" will pursue" 10 100)
  141. then
  142. echo "You're probably right to choose this..."
  143. echo "exiting upon demand..."
  144. echo "[$(date --rfc-3339=seconds)] T1 Abandoned on user demand, OS version too experimental" >> $user_path/faf.sh-$faf_sh_version.log
  145. exit 1
  146. else
  147. echo "OK! fingers crossed!"
  148. echo "continuing..."
  149. echo "[$(date --rfc-3339=seconds)] T1 wrong distribution, user-chosen continue." >> $user_path/faf.sh-$faf_sh_version.log
  150. fi
  151. else
  152. # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
  153. operating_system=$(uname -s)
  154. os_version=$(uname -r)
  155. install_basics_function
  156. if (whiptail --title "Distribution $operating_system $os_version is at present untested, Abort?" --yesno "Pursuing means you believe you know what you are doing and have pre-emptively read the contents of this .sh and are endowed with the needed skill to repair your OS, should things go wrong.\n\n Abort? \"Yes\" will stop the scipt, \"No\" will pursue" 10 100)
  157. then
  158. echo "You're probably right to choose this..."
  159. echo "exiting upon demand..."
  160. echo "[$(date --rfc-3339=seconds)] T1 Abandoned on user demand, OS version too experimental" >> $user_path/faf.sh-$faf_sh_version.log
  161. exit 1
  162. else
  163. echo "OK! fingers crossed!"
  164. echo "continuing..."
  165. echo "[$(date --rfc-3339=seconds)] T1 wrong distribution, user-chosen continue." >> $user_path/faf.sh-$faf_sh_version.log
  166. fi
  167. fi
  168.  
  169. echo "Distribution name + version + kernel version + architecture : "$operating_system" "$os_version" "$(uname -rm) >> $user_path/faf.sh-$faf_sh_version.log
  170. echo "-------------------------------------------------------------------------------------------------------" >> $user_path/faf.sh-$faf_sh_version.log
  171. echo "Hard storage setup :" >> $user_path/faf.sh-$faf_sh_version.log
  172. echo "_______________________________________________________________________________________________________" >> $user_path/faf.sh-$faf_sh_version.log
  173. lsblk_ouput=$(lsblk | grep -v 'loop')
  174. echo "$lsblk_ouput" >> $user_path/faf.sh-$faf_sh_version.log
  175. dfh_ouput=$(df -h --total | grep -v 'loop')
  176. echo "$dfh_ouput" >> $user_path/faf.sh-$faf_sh_version.log
  177. echo "_______________________________________________________________________________________________________" >> $user_path/faf.sh-$faf_sh_version.log
  178. echo "" >> $user_path/faf.sh-$faf_sh_version.log
  179.  
  180. function install_faf_function
  181. {
  182. # no more apt-install
  183. # Java install block
  184. echo "Now probing the Java status of this OS..."
  185. echo "[$(date --rfc-3339=seconds)] T1 Now probing the Java status of this OS..." >> $user_path/faf.sh-$faf_sh_version.log
  186. if [ -d /usr/lib/jvm/jdk-10.0.2 ]
  187. then
  188. echo "Java is already installed, moving on"
  189. echo "[$(date --rfc-3339=seconds)] T1 Java already installed!" >> $user_path/faf.sh-$faf_sh_version.log
  190. else
  191. # Download & install java 10 open jdk
  192. echo "Java 10 installation procedure..."
  193. echo "[$(date --rfc-3339=seconds)] T1 Java 10 installing..." >> $user_path/faf.sh-$faf_sh_version.log
  194. wget https://download.java.net/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_linux-x64_bin.tar.gz
  195. if [ "$operating_system" = "Debian GNU/Linux" ]
  196. then
  197. mkdir -p /usr/lib/jvm
  198. cd /usr/lib/jvm
  199. pv $user_path/openjdk-10.0.2_linux-x64_bin.tar.gz | tar xzp -C /usr/lib/jvm
  200. cd $user_path
  201. rm openjdk-10.0.2_linux-x64_bin.tar.gz
  202. update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-10.0.2/bin/java" 0
  203. update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-10.0.2/bin/javac" 0
  204. update-alternatives --set java /usr/lib/jvm/jdk-10.0.2/bin/java
  205. update-alternatives --set javac /usr/lib/jvm/jdk-10.0.2/bin/javac
  206. else
  207. sudo mkdir -p /usr/lib/jvm
  208. cd /usr/lib/jvm
  209. sudo pv ~/openjdk-10.0.2_linux-x64_bin.tar.gz | sudo tar xzp -C /usr/lib/jvm
  210. cd
  211. rm openjdk-10.0.2_linux-x64_bin.tar.gz
  212. sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-10.0.2/bin/java" 0
  213. sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-10.0.2/bin/javac" 0
  214. sudo update-alternatives --set java /usr/lib/jvm/jdk-10.0.2/bin/java
  215. sudo update-alternatives --set javac /usr/lib/jvm/jdk-10.0.2/bin/javac
  216. fi
  217. echo "" >> $user_path/.bashrc
  218. echo "" >> $user_path/.bashrc
  219. ! grep -q 'INSTALL4J_JAVA_HOME' $user_path/.bashrc > /dev/null && echo "export INSTALL4J_JAVA_HOME=/usr/lib/jvm/jdk-10.0.2" >> $user_path/.bashrc
  220. # /end Download & install java 10 open jdk
  221. fi
  222. # /end Java install block
  223. # make faf .desktop runner
  224. [ ! -d $user_path/.local/share/icons ] && mkdir -p .local/share/icons
  225. if [ ! -f $user_path/.local/share/icons/faf.png ]
  226. then
  227. echo "[$(date --rfc-3339=seconds)] T1 getting desktop launcher icon" >> $user_path/faf.sh-$faf_sh_version.log
  228. cd $user_path/.local/share/icons
  229. wget https://github.com/tatsujb/FAFICON/raw/master/faf.png
  230. fi
  231. if [ ! -f $user_path/.local/share/applications/faforever.desktop ]
  232. then
  233. echo "[$(date --rfc-3339=seconds)] T1 making desktop launcher" >> $user_path/faf.sh-$faf_sh_version.log
  234. cd $user_path/.local/share/applications
  235. echo '#!/usr/bin/env xdg-open' >> faforever.desktop
  236. echo "[Desktop Entry]" >> faforever.desktop
  237. echo "Version=$faf_version" >> faforever.desktop
  238. echo "Type=Application" >> faforever.desktop
  239. echo 'Exec=bash -c "cd '$user_path'/faf;export INSTALL4J_JAVA_HOME=/usr/lib/jvm/jdk-10.0.2; ./downlords-faf-client"' >> faforever.desktop
  240. echo "Name=FAF" >> faforever.desktop
  241. echo "Comment=Forged Alliance Forever Client" >> faforever.desktop
  242. echo "Icon=$user_path/.local/share/icons/faf.png" >> faforever.desktop
  243. chmod +x faforever.desktop
  244. fi
  245. cd $user_path
  246. # /end make faf .desktop runner
  247. # Download & install FAF client
  248. echo "now moving on to installing Downlord's FAF..."
  249. if [ -d $user_path/faf ]
  250. then
  251. rm -rf faf
  252. else
  253. echo "[$(date --rfc-3339=seconds)] T1 installing DOWNLORD" >> $user_path/faf.sh-$faf_sh_version.log
  254. mkdir faf
  255. cd faf
  256. rm -rf *
  257. faf_version_number=$(curl -v --silent https://api.github.com/repos/FAForever/downlords-faf-client/releases 2>&1 | grep '"tag_name": ' | head -n 1 | cut -f4,4 -d'"')
  258. faf_version=$( echo ${faf_version_number:1} | tr '.' '_' )
  259. wget https://github.com/FAForever/downlords-faf-client/releases/download/$faf_version_number/_dfc_unix_$faf_version.tar.gz
  260. pv _dfc_unix_$faf_version.tar.gz | tar xzp -C ~/faf
  261. mv downlords-faf-client-${faf_version_number:1}/{.,}* . 2>/dev/null
  262. rm -rf downlords-faf-client-${faf_version_number:1}
  263. rm _dfc_unix_$faf_version.tar.gz
  264. chmod +x downlords-faf-client
  265. chmod +x lib/faf-uid
  266. fi
  267. cd $user_path
  268. # /end Download & install FAF client
  269. }
  270.  
  271. function set_install_dir_function
  272. {
  273. directory=$(zenity --file-selection --directory --title $1)
  274. echo "[$(date --rfc-3339=seconds)] T1 folder set to $directory" >> $user_path/faf.sh-$faf_sh_version.log
  275. }
  276.  
  277.  
  278. if (whiptail --title "Do you need a Forged Alliance install?" --yesno "if you already have FA installed you can choose no, the default choice is yes (please install Fa for me)" 10 100)
  279. then
  280. already_fa=false
  281. if (whiptail --title "Install Forged Alliance to default dirrectory? (SDA)" --yesno "" 10 100)
  282. then
  283. default_dir=true
  284. echo "[$(date --rfc-3339=seconds)] T1 default dir chosen" >> $user_path/faf.sh-$faf_sh_version.log
  285. else
  286. default_dir=false
  287. echo "[$(date --rfc-3339=seconds)] T1 non-standart dir chosen" >> $user_path/faf.sh-$faf_sh_version.log
  288. set_install_dir_function "choose your desired Forged Alliance installation directory/folder"
  289.  
  290. fi
  291. else
  292. echo "[$(date --rfc-3339=seconds)] T1 FA already installed chosen" >> $user_path/faf.sh-$faf_sh_version.log
  293. what_to_do=$(whiptail --title "What do you wish to do?" --fb --menu "Choose an option" 15 100 4
  294. "1" "Remove FA an reinstall"
  295. "2" "Use my install of FA and configure it for proton use"
  296. "3" "FA is configured, I only want FAF " 3>&1 1>&2 2>&3)
  297. case $what_to_do in
  298. 1)
  299. echo "[$(date --rfc-3339=seconds)] T1 resintall FA chosen" >> $user_path/faf.sh-$faf_sh_version.log
  300. # this choice does not delete already existing FA. I chose to do this because I don't see the point.
  301. # SteamCMD already does not care whether game is already there or not and is always in overwrite mode.
  302. # and if user points to a dir (default or other) that is not where he installed FA,
  303. # then maybe it was intended and the user does want a second FA folder. (in the use-case of not being sure if the script's result is keep-worthy for example)
  304. already_fa=false
  305. if (whiptail --title "ReInstall Forged Alliance to default dirrectory? (SDA)" --yesno "" 10 100)
  306. then
  307. default_dir=true
  308. echo "[$(date --rfc-3339=seconds)] T1 default dir chosen" >> $user_path/faf.sh-$faf_sh_version.log
  309. else
  310. default_dir=false
  311. echo "[$(date --rfc-3339=seconds)] T1 non-standart dir chosen" >> $user_path/faf.sh-$faf_sh_version.log
  312. set_install_dir_function "choose your desired Forged Alliance installation directory/folder"
  313. fi
  314. ;;
  315. 2)
  316. echo "[$(date --rfc-3339=seconds)] T1 keep but configure FA chosen" >> $user_path/faf.sh-$faf_sh_version.log
  317. already_fa=true
  318. #if (whiptail --title "is Forged Alliance installed to the default dirrectory? (SDA)" --yesno "" 10 100)
  319. #then
  320. # default_dir=true
  321. # echo "[$(date --rfc-3339=seconds)] T1 default dir chosen" >> $user_path/faf.sh-$faf_sh_version.log
  322. #else
  323. # default_dir=false
  324. # echo "[$(date --rfc-3339=seconds)] T1 non-standart dir chosen" >> $user_path/faf.sh-$faf_sh_version.log
  325. # set_install_dir_function "where is Forged Alliance installed to? (choose the folder that contains Forged Alliance)")
  326. #fi
  327. ;;
  328. 3)
  329. echo "[$(date --rfc-3339=seconds)] T1 keep and dont configure FA chosen" >> $user_path/faf.sh-$faf_sh_version.log
  330. install_faf_function
  331. echo "installed faf only, as per user demand, nothing else to do, exiting."
  332. exit 0
  333. esac
  334. fi
  335.  
  336.  
  337. if $already_fa
  338. then null
  339. else
  340. echo "[$(date --rfc-3339=seconds)] T1 FA not installed chosen" >> $user_path/faf.sh-$faf_sh_version.log
  341. while [ -z "$steam_user_name" ]
  342. do
  343. echo "steam user name :"
  344. read steam_user_name
  345. done
  346. while [ -z "$steam_password" ]
  347. do
  348. echo "steam password :"
  349. read -s steam_password
  350. done
  351. echo "[$(date --rfc-3339=seconds)] T1 Steam credentials entrusted to scritp" >> $user_path/faf.sh-$faf_sh_version.log # NOTE THAT THIS IS NOT MY IDEAL SOLUTION BUT I HAVENT YET FOUND BETTER
  352.  
  353. if (whiptail --title "Use Gallium Nine Proton instead of vanilla Proton?" --yesno "If you don't know what Gallium Nine is or don't care, choose \"No\"." 10 100)
  354. then
  355. gallium_nine=true
  356. echo 'PROTON_NO_ESYNC=1, PROTON_DUMP_DEBUG_COMMANDS=1, PROTON_USE_GALLIUM_NINE=1, PROTON_GALLIUM_NINE_MODULEPATH="/usr/lib/i386-linux-gnu/d3d/d3dadapter9.so.1:/usr/lib/x86_64-linux-gnu/d3d/d3dadapter9.so.1" %command%' > $user_path/"the contents of this file are to be pasted in the forged alliance properties launch options"
  357. echo "[$(date --rfc-3339=seconds)] T1 Gallium Nine chosen" >> $user_path/faf.sh-$faf_sh_version.log
  358. else
  359. echo 'PROTON_NO_ESYNC=1, PROTON_DUMP_DEBUG_COMMANDS=1 %command%' > $user_path/"the contents of this file are to be pasted in the forged alliance properties launch options"
  360. gallium_nine=false
  361. echo "[$(date --rfc-3339=seconds)] T1 Vanilla Proton chosen" >> $user_path/faf.sh-$faf_sh_version.log
  362. fi
  363. fi
  364.  
  365. # edit sources (debian)
  366. if [ "$operating_system" = "Debian GNU/Linux" ]
  367. then
  368. if grep -q "debian.org/debian/ stretch main contrib non-free" /etc/apt/sources.list > /dev/null
  369. then
  370. echo "[$(date --rfc-3339=seconds)] T1 editing debian sources : stretch already correct" >> $user_path/$user_path/faf.sh-$faf_sh_version.log
  371. else
  372. echo "[$(date --rfc-3339=seconds)] T1 editing debian sources : stretch edited" >> $user_path/faf.sh-$faf_sh_version.log
  373. sed -i "s_debian.org/debian/ stretch main contrib_debian.org/debian/ stretch main contrib non-free_" /etc/apt/sources.list
  374. fi
  375.  
  376. if grep -q "http://security.debian.org/debian-security stretch/updates main contrib non-free" /etc/apt/sources.list > /dev/null
  377. then
  378. echo "[$(date --rfc-3339=seconds)] T1 editing debian sources : stretch/updates already correct" >> $user_path/faf.sh-$faf_sh_version.log
  379. else
  380. echo "[$(date --rfc-3339=seconds)] T1 editing debian sources : stretch/updates edited" >> $user_path/faf.sh-$faf_sh_version.log
  381. sed -i "s_http://security.debian.org/debian-security stretch/updates main contrib_http://security.debian.org/debian-security stretch/updates main contrib non-free_" /etc/apt/sources.list
  382. fi
  383.  
  384. if grep -q "debian.org/debian/ stretch-updates main contrib non-free" /etc/apt/sources.list > /dev/null
  385. then
  386. echo "[$(date --rfc-3339=seconds)] T1 editing debian sources : stretch-updates already correct" >> $user_path/faf.sh-$faf_sh_version.log
  387. else
  388. echo "[$(date --rfc-3339=seconds)] T1 editing debian sources : stretch-updates edited" >> $user_path/faf.sh-$faf_sh_version.log
  389. sed -i "s_debian.org/debian/ stretch-updates main contrib_debian.org/debian/ stretch-updates main contrib non-free_" /etc/apt/sources.list
  390. fi
  391.  
  392. if grep -q "deb http://ftp.*.debian.org/debian/ stretch-proposed-updates main contrib non-free" /etc/apt/sources.list > /dev/null
  393. then
  394. echo "[$(date --rfc-3339=seconds)] T1 editing debian sources : proposed already present" >> $user_path/faf.sh-$faf_sh_version.log
  395. else
  396. donwload_country=$(grep "deb http://ftp." /etc/apt/sources.list | head -1 | cut -d. -f2)
  397. echo "[$(date --rfc-3339=seconds)] T1 editing debian sources : added proposed" >> $user_path/faf.sh-$faf_sh_version.log
  398. echo "deb http://ftp.$donwload_country.debian.org/debian/ stretch-proposed-updates main contrib non-free" >> /etc/apt/sources.list
  399. fi
  400.  
  401. # edit sources (ubuntu-based)
  402. else
  403. if grep -Fxq "# deb http://archive.canonical.com/ubuntu cosmic partner" /etc/apt/sources.list
  404. then
  405. echo "[$(date --rfc-3339=seconds)] T1 enabled partners" >> ~/'faf.sh-'$faf_sh_version'.log'
  406. sudo sed -i 's/# deb http:\/\/archive.canonical.com\/ubuntu cosmic partner/deb http:\/\/archive.canonical.com\/ubuntu cosmic partner/g' /etc/apt/sources.list
  407. else
  408. echo "[$(date --rfc-3339=seconds)] T1 did not enable partners, hoping it was already enabled." >> ~/'faf.sh-'$faf_sh_version'.log'
  409. fi
  410. fi
  411.  
  412. to_be_installed=0
  413. if [ $(command -v steam) ]
  414. then
  415. echo "steam is already installed, proceeding..."
  416. echo "[$(date --rfc-3339=seconds)] T1 steam is already installed, proceeding..." >> $user_path/faf.sh-$faf_sh_version.log
  417. else
  418. echo "[$(date --rfc-3339=seconds)] T1 steam was not yet installed, installing..." >> $user_path/faf.sh-$faf_sh_version.log
  419. if [ "$operating_system" != "Zorin OS" ]
  420. then
  421. if [ "$operating_system" = "Debian GNU/Linux" ]
  422. then
  423. echo steam steam/question select "I AGREE" | debconf-set-selections
  424. echo steam steam/license note '' | debconf-set-selections
  425. else
  426. echo steam steam/question select "I AGREE" | sudo debconf-set-selections
  427. echo steam steam/license note '' | sudo debconf-set-selections
  428. fi
  429. fi
  430. if [ "$operating_system" = "Debian GNU/Linux" ]
  431. then
  432. usermod -a -G video,audio $real_user
  433. dpkg --add-architecture i386
  434. fi
  435. to_be_installed=$((to_be_installed+1))
  436. fi
  437. if [ $(command -v curl) ]
  438. then
  439. echo "[$(date --rfc-3339=seconds)] T1 curl is already installed, proceeding..." >> $user_path/faf.sh-$faf_sh_version.log
  440. echo "curl is already installed, proceeding..."
  441. else
  442. echo "[$(date --rfc-3339=seconds)] T1 curl was not yet installed, installing..." >> $user_path/faf.sh-$faf_sh_version.log
  443. to_be_installed=$((to_be_installed+2))
  444. fi
  445. if [ $(command -v pv) ]
  446. then
  447. echo "[$(date --rfc-3339=seconds)] T1 pv is already installed, proceeding..." >> $user_path/faf.sh-$faf_sh_version.log
  448. echo "pv is already installed, proceeding..."
  449. else
  450. echo "[$(date --rfc-3339=seconds)] T1 pv was not yet installed, installing..." >> $user_path/faf.sh-$faf_sh_version.log
  451. to_be_installed=$((to_be_installed+4))
  452. fi
  453. if [ $(command -v jq) ]
  454. then
  455. echo "[$(date --rfc-3339=seconds)] T1 jq is already installed, proceeding..." >> $user_path/faf.sh-$faf_sh_version.log
  456. echo "jq is already installed, proceeding..."
  457. else
  458. echo "[$(date --rfc-3339=seconds)] T1 jq was not yet installed, installing..." >> $user_path/faf.sh-$faf_sh_version.log
  459. to_be_installed=$((to_be_installed+8))
  460. fi
  461. if [ "$operating_system" = "Debian GNU/Linux" ]
  462. then
  463. apt update -y
  464. apt -y full-upgrade
  465. case "${to_be_installed}" in
  466. 0)
  467. echo "nothing to install";;
  468. 1)
  469. apt install -y steam;;
  470. 2)
  471. apt install -y curl;;
  472. 3)
  473. apt install -y curl steam;;
  474. 4)
  475. apt install -y pv;;
  476. 5)
  477. apt install -y pv steam;;
  478. 6)
  479. apt install -y curl pv;;
  480. 7)
  481. apt install -y curl pv steam;;
  482. 8)
  483. apt install -y jq;;
  484. 9)
  485. apt install -y jq steam;;
  486. 10)
  487. apt install -y curl jq;;
  488. 11)
  489. apt install -y curl jq steam;;
  490. 12)
  491. apt install -y pv jq;;
  492. 13)
  493. apt install -y pv jq steam;;
  494. 14)
  495. apt install -y curl jq pv;;
  496. 15)
  497. apt install -y jq curl pv steam
  498. esac
  499. else
  500. sudo apt update -y
  501. sudo apt -y full-upgrade
  502. case "${to_be_installed}" in
  503. 0)
  504. echo "nothing to install";;
  505. 1)
  506. sudo apt install -y steam;;
  507. 2)
  508. sudo apt install -y curl;;
  509. 3)
  510. sudo apt install -y curl steam;;
  511. 4)
  512. sudo apt install -y pv;;
  513. 5)
  514. sudo apt install -y pv steam;;
  515. 6)
  516. sudo apt install -y curl pv;;
  517. 7)
  518. sudo apt install -y curl pv steam;;
  519. 8)
  520. sudo apt install -y jq;;
  521. 9)
  522. sudo apt install -y jq steam;;
  523. 10)
  524. sudo apt install -y curl jq;;
  525. 11)
  526. sudo apt install -y curl jq steam;;
  527. 12)
  528. sudo apt install -y pv jq;;
  529. 13)
  530. sudo apt install -y pv jq steam;;
  531. 14)
  532. sudo apt install -y curl jq pv;;
  533. 15)
  534. sudo apt install -y jq curl pv steam
  535. esac
  536. fi
  537. #########################################################################################################################
  538. # #
  539. # WIP! have not figured out a way to toggle proton-> [on] & set set launch options via command line, right now #
  540. # you have to do it yourself when steam starts up while the script is running #
  541. # #
  542. #########################################################################################################################
  543. middlescript='[ '$gallium_nine' ] && echo "installing gallium/proton and running steam...";
  544. echo "expecting you to type in Forged Alliances Launch options";
  545. echo "reminder : look in your home folder, theres a file there with the contents to be pasted";
  546. echo "once thats done edit steam settings in order to enable Proton for all games";
  547. if '$already_fa';
  548. then null;
  549. else [ '$gallium_nine' ] && echo "it should have Gallium pre-selected already, this is what you want, just tick the box next to it.";
  550. echo "";
  551. echo "";
  552. echo "[$(date --rfc-3339=seconds)] T2 running steam" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  553. if '$gallium_nine';
  554. then mkdir -p '$user_path'/.steam/compatibilitytools.d;
  555. proton_version=$(curl -v --silent https://api.github.com/repos/popsUlfr/Proton/releases 2>&1 | grep "tag_name" | head -n 1 | cut -f4,4 -d"\"");
  556. proton_temp_value=$(curl -v --silent https://api.github.com/repos/popsUlfr/Proton/releases 2>&1 | grep "target_commitish" | head -n 1 | cut -f4,4 -d"\"" | sed "s/[^_]\+/\L\u&/g");
  557. proton_version_number=${proton_temp_value/_G/-6_G};
  558. proton_name=$proton_version_number"_"${proton_version##*-};
  559. wget https://github.com/popsUlfr/Proton/releases/download/$proton_version/$proton_name.tar.xz;
  560. pv '$user_path'/$proton_name.tar.xz | tar xp -J -C '$user_path'/.steam/compatibilitytools.d;
  561. rm '$user_path'/$proton_name.tar.xz;
  562. fi;
  563. echo "starting Steam...";
  564. echo "[$(date --rfc-3339=seconds)] T2 starting Steam..." >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  565. steam -login '$steam_user_name' '$steam_password';
  566. echo "editing launchparameters";
  567. echo "starting Forged Alliance Download...";
  568. echo "[$(date --rfc-3339=seconds)] T2 starting Forged Alliance Download..." >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  569. if '$default_dir';
  570. then while [ \( ! -d ~/.steam/steam/steamapps/common/Supreme* \) -a \( ! -d ~/.steam/steam/SteamApps/common/Supreme* \) ];
  571. do steamcmd +login '$steam_user_name' '$steam_password' +@sSteamCmdForcePlatformType windows +app_update 9420 +quit;
  572. done;
  573. else while [ ! -d '$directory'/bin ];
  574. do steamcmd +login '$steam_user_name' '$steam_password' +@sSteamCmdForcePlatformType windows +force_install_dir '$directory' +app_update 9420 +quit;
  575. done;https://youtu.be/1hYR2o1--8s
  576. cd '$directory';
  577. mkdir -p steamapps/common/Supreme\ Commander\ Forged\ Alliance;
  578. #mv -t * !\(common|steamapps\) steamapps/common/Supreme\ Commander\ Forged\ Alliance/;
  579. sleep 100;
  580. cd '$user_path';
  581. fi;
  582. echo "steamCMD terminated (in a good way), starting FA to finalize install";
  583. echo "[$(date --rfc-3339=seconds)] T2 steamCMD terminated (in a good way), starting FA to finalize install" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  584. fi;
  585. steam -login '$steam_user_name' '$steam_password' -applaunch 9420 -shutdown;
  586. echo "FA install done. Waiting in case it isnt";
  587. if '$already_fa';
  588. then null;
  589. else cp -f /tmp/proton_'$real_user'/run '$user_path'/faf/
  590. fi;
  591. echo "making map & mods symbolic links";
  592. echo "[$(date --rfc-3339=seconds)] T2 making map & mods symbolic links" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  593. if [ -d '$user_path'/.steam/steam/steamapps ] ;
  594. then steamapps="steamapps";
  595. echo "[$(date --rfc-3339=seconds)] T2 steamapps found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  596. if [ -d '$user_path'/.steam/steam/steamapps/common/Supreme* ] ;
  597. then echo "[$(date --rfc-3339=seconds)] T2 Supreme Commander folder found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  598. cd '$user_path'/.steam/steam/steamapps/common/Supreme\ Commander\ Forged\ Alliance;
  599. ln -s '$user_path'/My\ Games/Gas\ Powered\ Games/Supreme\ Commander\ Forged\ Alliance/Maps/ Maps;
  600. ln -s '$user_path'/My\ Games/Gas\ Powered\ Games/Supreme\ Commander\ Forged\ Alliance/Mods/ Mods;
  601. else echo "[$(date --rfc-3339=seconds)] T2 Supreme Commander folder not found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  602. fi;
  603. if [ -d '$user_path'/.steam/steam/steamapps/compatdata/9420/pfx/drive_c/users/steamuser ] ;
  604. then echo "[$(date --rfc-3339=seconds)] T2 steamuser profile folder found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  605. cd '$user_path'/.steam/steam/steamapps/compatdata/9420/pfx/drive_c/users/steamuser;
  606. rm -rf My\ Documents;
  607. mkdir My\ Documents;
  608. cd My\ Documents;
  609. ln -s '$user_path'/My\ Games/ My\ Games;
  610. else echo "[$(date --rfc-3339=seconds)] T2 steamuser profile folder not found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  611. fi;
  612. elif [ -d '$user_path'/.steam/steam/SteamApps ];
  613. then steamapps="SteamApps";
  614. echo "[$(date --rfc-3339=seconds)] T2 SteamApps found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  615. if [ -d '$user_path'/.steam/steam/SteamApps/common/Supreme* ] ;
  616. then echo "[$(date --rfc-3339=seconds)] T2 Supreme Commander folder found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  617. cd '$user_path'/.steam/steam/SteamApps/common/Supreme\ Commander\ Forged\ Alliance;
  618. ln -s '$user_path'/My\ Games/Gas\ Powered\ Games/Supreme\ Commander\ Forged\ Alliance/Maps/ Maps;
  619. ln -s '$user_path'/My\ Games/Gas\ Powered\ Games/Supreme\ Commander\ Forged\ Alliance/Mods/ Mods;
  620. else echo "[$(date --rfc-3339=seconds)] T2 Supreme Commander folder not found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  621. fi;
  622. if [ -d '$user_path'/.steam/steam/steamapps/compatdata/9420/pfx/drive_c/users/steamuser ] ;
  623. then echo "[$(date --rfc-3339=seconds)] T2 steamuser profile folder found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  624. cd '$user_path'.steam/steam/SteamApps/compatdata/9420/pfx/drive_c/users/steamuser;
  625. rm -rf My\ Documents;
  626. mkdir My\ Documents;
  627. cd My\ Documents;
  628. ln -s '$user_path'/My\ Games/ My\ Games;
  629. else echo "[$(date --rfc-3339=seconds)] T2 steamuser profile folder not found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  630. fi;
  631. else echo "[$(date --rfc-3339=seconds)] T2 neither cammel case (SteamApps), nor lowercase (steamapps) found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  632. echo "UNACCEPTABLEEEEEEEEEEEEEEEE";
  633. exit 1;
  634. fi;
  635. if '$gallium_nine' ;
  636. then cp -rf '$user_path'/.steam/compatibilitytools.d/$proton_name '$user_path'/.steam/compatibilitytools.d/Proton;
  637. mv '$user_path'/.steam/compatibilitytools.d/Proton '$user_path'/.steam/steam/$steamapps/common;
  638. else cp -rf '$user_path'/.steam/steam/$steamapps/common/Proton* '$user_path'/.steam/steam/$steamapps/common/Proton;
  639. fi;
  640. [ \( -d '$user_path'/.steam/steam/steamapps/common/Proton \) -o \( -d '$user_path'/.steam/steam/SteamApps/common/Proton \) ] && echo "[$(date --rfc-3339=seconds)] T2 PROTON folder found" >> '$user_path'/faf.sh-'$faf_sh_version'.log || echo "[$(date --rfc-3339=seconds)] T2 Proton folder not found" >> '$user_path'/faf.sh-'$faf_sh_version'.log;
  641. cd '$user_path';
  642. source .bashrc;
  643. eval "$(cat .bashrc | tail -n +10)";
  644. echo "Finished thread two (install & run steam, steamcmd, FA) without issue, starting (FAF)...";
  645. echo "[$(date --rfc-3339=seconds)] T2 Finished thread two (install & run steam, steamcmd, FA) without issue, starting (FAF)..." >> '$user_path'/faf.sh-'$faf_sh_version'.log;'
  646. gnomeTerminalFirstConsoleVar='gnome-terminal --tab --active --title="install & run steam, steamcmd, FA" -- bash -c '"'"''
  647. konsoleFirstConsoleVar='konsole -e /bin/bash --rcfile <(echo '"'"''
  648. xtermFirstConsoleVar='xterm -T "install & run steam, steamcmd, FA" -e '"'"''
  649. gnomeTerminalSecondConsoleVar='gnome-terminal --tab --title="(FAF)" -- bash -c "cd ~/faf; ./downlords-faf-client";'"'"''
  650. konsoleSecondConsoleVar='konsole -e /bin/bash --rcfile <(echo "cd ~/faf; ./downlords-faf-client; exit 0") &'"'"') &'
  651. xtermSecondConsoleVar=' xterm -T "(FAF)" -e "cd ~/faf; ./downlords-faf-client";'"'"' &'
  652. # this "eval" solution doesn't seem like it will be robust enough to work on any os. suggestions welcome
  653. if [ "$operating_system" = "Kubuntu" ]
  654. then
  655. eval "$konsoleFirstConsoleVar $middlescript $konsoleSecondConsoleVar"
  656. elif [ "$operating_system" = "elementary OS" ]
  657. then
  658. eval "$xtermFirstConsoleVar $middlescript $xtermSecondConsoleVar"
  659. else
  660. eval "$gnomeTerminalFirstConsoleVar $middlescript $gnomeTerminalSecondConsoleVar"
  661. fi
  662. # source $user_path/.bashrc be it in main thread or in tab, has no effect the user will have to run it himself.
  663. # end of second thread
  664. # finalising apt-install
  665. echo "[$(date --rfc-3339=seconds)] T1 start of second thread did not crash first thread" >> $user_path/faf.sh-$faf_sh_version.log
  666. if ! dpkg-query -W -f='${Status}' lib32gcc1 | grep "ok installed"
  667. then
  668. echo "[$(date --rfc-3339=seconds)] T1 lib32gcc1 was not yet installed, installing..." >> $user_path/faf.sh-$faf_sh_version.log
  669. if [ "$operating_system" = "Debian GNU/Linux" ]
  670. then
  671. apt install -y lib32gcc1
  672. else
  673. sudo apt install -y lib32gcc1
  674. fi
  675. else
  676. echo "[$(date --rfc-3339=seconds)] T1 lib32gcc1 is already installed, proceeding..." >> $user_path/faf.sh-$faf_sh_version.log
  677. echo "lib32gcc1 is already installed, proceeding..."
  678. fi
  679. if [ $(command -v steamcmd) ]
  680. then
  681. echo "[$(date --rfc-3339=seconds)] T1 steam CMD is already installed, proceeding..." >> $user_path/faf.sh-$faf_sh_version.log
  682. echo "steam CMD is already installed, proceeding..."
  683. else
  684. echo "[$(date --rfc-3339=seconds)] T1 steam CMD was not yet installed, installing..." >> $user_path/faf.sh-$faf_sh_version.log
  685. if [ "$operating_system" != "Zorin OS" ]
  686. then
  687. if [ "$operating_system" = "Debian GNU/Linux" ]
  688. then
  689. echo steamcmd steam/question select "I AGREE" | debconf-set-selections
  690. echo steamcmd steam/license note '' | debconf-set-selections
  691. else
  692. echo steamcmd steam/question select "I AGREE" | sudo debconf-set-selections
  693. echo steamcmd steam/license note '' | sudo debconf-set-selections
  694. fi
  695. fi
  696. useradd -m steam
  697. cd /home/steam
  698. if [ "$operating_system" = "Debian GNU/Linux" ]
  699. then
  700. apt install -y steamcmd
  701. else
  702. sudo apt install -y steamcmd
  703. fi
  704. cd $user_path
  705. fi
  706. if ! dpkg-query -W -f='${Status}' libnss3-tools | grep "ok installed"
  707. then
  708. echo "[$(date --rfc-3339=seconds)] T1 libnss3 was not yet installed, installing..." >> $user_path/faf.sh-$faf_sh_version.log
  709. if [ "$operating_system" = "Debian GNU/Linux" ]
  710. then
  711. apt install -y libnss3-tools
  712. else
  713. sudo apt install -y libnss3-tools
  714. fi
  715. else
  716. echo "[$(date --rfc-3339=seconds)] T1 libnss3 is already installed, proceeding..." >> $user_path/faf.sh-$faf_sh_version.log
  717. echo "libnss3 is already installed, proceeding..."
  718. fi
  719. if [ "$operating_system" = "Debian GNU/Linux" ]
  720. then
  721. [ $gallium_nine ] && apt install -y libd3dadapter9-mesa:i386 libd3dadapter9-mesa
  722. apt autoremove -y
  723. apt autoclean
  724. else
  725. [ $gallium_nine ] && sudo apt install -y libd3dadapter9-mesa:i386 libd3dadapter9-mesa
  726. sudo apt autoremove -y
  727. sudo apt autoclean
  728. fi
  729.  
  730. install_faf_function
  731.  
  732. # wait for user to log in
  733. echo "please switch to opened FAF client. Waiting on user to log in"
  734. echo ""
  735. no_login=true
  736. i=1
  737. sp="/-\|"
  738. echo -n "waiting... "
  739. while $no_login
  740. do
  741. printf "\b${sp:i++%${#sp}:1}"
  742. grep --no-messages '"username": "' $user_path/.faforever/client.prefs && no_login=false
  743. sleep 1
  744. done
  745. echo "done looping!"
  746. sleep 2
  747. kill -9 $(pgrep java | tail -1)
  748. # editting client.prefs :
  749. if [ -d '$user_path'/.steam/steam/SteamApps ]
  750. then
  751. steamapps="SteamApps"
  752. else
  753. steamapps="steamapps"
  754. fi
  755. jq --arg user_path "$user_path" --arg steamapps "$steamapps" '
  756. .forgedAlliance += {
  757. installationPath: ($user_path + "/.steam/steam/" + $steamapps + "/common/Supreme Commander Forged Alliance"),
  758. path: ($user_path + "/.steam/steam/" + $steamapps + "/common/Supreme Commander Forged Alliance"),
  759. preferencesFile: ($user_path + "/.steam/steam/" + $steamapps + "/compatdata/9420/pfx/drive_c/users/steamuser/Local Settings/Application Data/Gas Powered Games/Supreme Commander Forged Alliance/Game.prefs"),
  760. executableDecorator: ($user_path + "/faf/run \"%s\"")
  761. }' $user_path/.faforever/client.prefs > $user_path/.faforever/client.prefs.tmp
  762. mv $user_path/.faforever/client.prefs.tmp $user_path/.faforever/client.prefs
  763. echo "done editting!"
  764. gtk-launch faforever
  765. echo "Finished thread one (proton/downlord/open-jdk/bashrc) without issue..."
  766. echo "[$(date --rfc-3339=seconds)] T1 Finished thread one. (proton/downlord/open-jdk/bashrc)" >> $user_path/faf.sh-$faf_sh_version.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement