Skip to content

Commit e36c1a4

Browse files
committed
Removes mac installation
1 parent ec27350 commit e36c1a4

File tree

2 files changed

+20
-52
lines changed

2 files changed

+20
-52
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ docker run -it -p 127.0.0.1:8080:8080 -v "$PWD:/home/coder/project" -u "$(id -u)
2222

2323
### Installation
2424

25+
#### Linux
26+
2527
```bash
26-
curl -s https://raw.githubusercontent.com/cdr/code-server/issue-1396/install_helper.sh | bash -s
28+
curl --silent https://raw.githubusercontent.com/cdr/code-server/issue-1396/install_helper.sh | bash
2729
```
2830

2931
### Requirements

install_helper.sh

+17-51
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env bash
2+
# install_helper allows for easy installation of code-server on Linux systems
3+
# the latest official release is pulled from the Github API, where the proper asset
4+
# is then unpackaged and installed into ~/.local/share/code-server/<version>
5+
6+
# The code-server binary is linked to ~/.local/share/code-server/bin/code-server
7+
28
set -euo pipefail
39

4-
RED='\033[0;31m'
5-
NC='\033[0m' # No Color
10+
RED=1
611

712
get_releases() {
813
curl --silent "https://api.github.com/repos/cdr/code-server/releases/latest" |
@@ -35,8 +40,10 @@ linux_install() {
3540
rm code-server*.tar.gz
3641

3742
if [ -d $lib_path ]; then
38-
echo -e "${RED}-- ERROR: v$version already found in $lib_path${NC}"
39-
echo -e "${RED}-- ERROR: To reinstall, first delete this directory${NC}"
43+
tput setaf $RED
44+
echo "-- ERROR: v$version already found in $lib_path"
45+
echo "-- ERROR: To reinstall, first delete this directory"
46+
tput sgr 0
4047
rm -rf -f $temp_path
4148
exit 1
4249
fi
@@ -48,60 +55,19 @@ linux_install() {
4855
mkdir -p $bin_dir
4956
ln -f -s $lib_path/code-server $bin_path
5057

51-
rm -rf -f $temp_path
52-
53-
if [ $bin_dir != *"$PATH"* ]; then
54-
echo -e "${RED}-- WARNING: $bin_dir is not in your \$PATH${NC}"
58+
code_server_bin=$(which code-server || true)
59+
if [ "$code_server_bin" == "" ]; then
60+
tput setaf $RED
61+
echo "-- WARNING: $bin_dir is not in your \$PATH"
62+
tput sgr 0
5563
fi
5664

57-
echo "-- Successfully installed code-server at $bin_path"
58-
}
59-
60-
mac_install() {
61-
bin_path=/usr/local/bin
62-
lib_path=/usr/local/lib
63-
64-
releases=$(get_releases)
65-
package=$(echo "$releases" | grep 'darwin' | sed -E 's/.*"([^"]+)".*/\1/')
66-
version=$(echo $releases | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
67-
68-
temp_path=/tmp/code-server-$version
69-
70-
if [ -d $temp_path ]; then
71-
rm -rf $temp_path
72-
fi
73-
74-
mkdir $temp_path
75-
cd $temp_path
76-
77-
echo "-- Downloading code-server v$version"
78-
wget $package > /dev/null
79-
80-
echo "-- Unpacking release"
81-
unzip code-server-* > /dev/null
82-
rm code-server-*.zip
83-
84-
echo "-- Installing binary"
85-
if [ -d $lib_path/code-server ]; then
86-
backup=$lib_path/BACKUP_$(date +%s)_code-server/
87-
mv $lib_path/code-server/ $backup
88-
echo "-- INFO: moved old code-server lib directory to $backup"
89-
fi
90-
mkdir -p $lib_path/code-server
91-
mv ./code-server-*/* $lib_path/code-server/
92-
93-
rm -f $bin_path/code-server
94-
ln -s $lib_path/code-server/code-server $bin_path/code-server
95-
9665
rm -rf -f $temp_path
97-
98-
echo "-- Successfully installed code-server at $bin_path/code-server"
66+
echo "-- Successfully installed code-server at $bin_path"
9967
}
10068

10169
if [[ $OSTYPE == "linux-gnu" ]]; then
10270
linux_install
103-
elif [[ $OSTYPE == "darwin"* ]]; then
104-
mac_install
10571
else
10672
echo "Unknown operating system. Not installing."
10773
exit 1

0 commit comments

Comments
 (0)