Commit e383803b authored by Oskar Skog's avatar Oskar Skog

Pre 0.3.8: Change of plans: ditch Windows support

parent b573764e
2016-10-20 Oskar Skog <oskar.skog.finland@gmail.com>
0.3.8
* cygwin-sshd, Makefile.static: Cygwin uninstaller.
*: Removed Windows support. (Going to create that in a different
repo.)
2016-10-02 Oskar Skog <oskar.skog.finland@gmail.com>
0.3.7
......
......@@ -17,9 +17,6 @@ Asterisk marks that the file will be created during building.
Makefile.static The source file for Makefile
NEWS --
README (It's an order! :)
Windows-admin.bat Installation script for Windows (auto-fetch Cygwin)
Windows-user.bat Installation script for Windows (auto-fetch Cygwin)
Windows.txt Installation instructions for Windows
* anonymine (Generated by make)
anonymine.py The curses interface for game (interface/engine)
anonymine_engine.py The engine part of the game (interface/engine)
......@@ -30,7 +27,6 @@ Asterisk marks that the file will be created during building.
configure See "INSTALL"
configure.py Used internally by configure
cursescfg The configuration file for the curses interface
cygwin-sshd Cygwin specific stuff to install and configure SSHd.
enginecfg.default
* enginecfg.out The configuration file for the game's engine
? enginecfg.user Create this yourself if you want to
......@@ -40,7 +36,6 @@ Asterisk marks that the file will be created during building.
desktop/ Non-essential files for the graphical environments:
FILES List of files.
README Overview of the contents of the desktop directory.
* rmssh File created by cygwin-sshd
Game construction
......
......@@ -117,7 +117,6 @@ INSTALLATION
freedesktop 'true' or 'false'; "Linux" desktop
macosx 'true' or 'false'; Mac OS X
windows 'true' or 'false'; Windows (Cygwin)
NOTE 1
......@@ -243,13 +242,6 @@ INSTALLATION
tarballs
make tarballs
zip
NOTE: Requires unix2dos(1) and zip(1).
Generate an archive suitable for Windrugs users.
- zip
- CRLF line endings
- .txt
release
(You are me.)
......
Installation instructions for Windows
=====================================
The game doesn't work on native Windows, so it will install Cygwin
automatically.
Notes
=====
- It is known that certain anti-virus programs can interfere with
Cygwin. https://cygwin.com/faq/faq.html#faq.using.bloda
- Cygwin will require approx 200 MB of disk space.
- There seems to be some issue with resizing, possibly the terminals
fault.
1. Download the zip file (Windows version of the game).
2. Extract the directory anonymine-x.y.z from the archive.
(Move the folder anonymine-x.y.z from the zip to somewhere else.)
3. Enter that folder and start Windows-admin[.bat] or Windows-user[.bat].
(Windows-user.bat will install Cygwin in your home directory and
doesn't require administrator privileges.)
*4. After a while, the Cygwin installer will launch and ask you to select
a mirror to download Cygwin from. After choosing the mirror you will
only have to click "next" a few times.
(This will only happen the first time you install the game.)
5. The Cygwin installer will launch to install all dependencies of the
game. You will only have to click "next" a few times.
......@@ -22,7 +22,6 @@ VERSION := pre-0.3.8
# script.
# freedesktop == "" if not freedesktop.org DE.
# windows == "" if not on Windows.
# macosx == "" if not on Mac OS X.
# See "INSTALL".
......@@ -37,14 +36,14 @@ POST_UNINSTALL = true
##############################################################################
verbose ?= true
info := test "$(verbose)" != true || echo '//'
# Desktop specific prefixes:
# FD_ freedesktop.org
# OSX_ Mac OS X
# CYG_ Cygwin
# W_ Cygwin, "temporary" variables
MAIN_SRC := $(srcdir)$(NAME).py
MAIN_STAGE := $(builddir)$(NAME)
......@@ -71,16 +70,13 @@ OSX_MK_INFO_PLIST := $(srcdir)desktop/Info.plist.py
OSX_ICON := $(builddir)icon.icns
OSX_MK_ICON := $(srcdir)desktop/icon.icns.py
# Windows/Cygwin, see desktop/README
CYG_ICO_SRC := $(srcdir)desktop/$(NAME).ico
CYG_ICO_DIR := $(DESTDIR)$(prefix)/share/pixmaps
CYG_ICO_DEST := $(CYG_ICO_DIR)/$(NAME).ico
# make clean
ALL_STAGE := "$(MAIN_STAGE)" "$(OSX_WRAPPER)" "$(OSX_INFO_PLIST)" \
"$(OSX_ICON)" "$(builddir)check.py" "$(FD_DESKTOP_STAGE)" \
"$(ENGINECFG_STAGE)" "$(builddir)mkenginecfg.py"
all : $(MAIN_STAGE) $(ENGINECFG_STAGE)
@$(info) 'Maybe building .desktop and app/bundle'
@if "$(freedesktop)"; then \
......@@ -90,21 +86,25 @@ all : $(MAIN_STAGE) $(ENGINECFG_STAGE)
cd "$(builddir)" && make build-macosx > /dev/null; \
fi
$(MAIN_STAGE) : $(MAIN_SRC) $(srcdir)Makefile.static
@$(info) 'Creating the appropriate shebang line'
@echo "#!`which python`" > "$(MAIN_STAGE)"
@sed -e "$(MAIN_STAGE_SED1)" "$(MAIN_SRC)" \
| sed -e "$(MAIN_STAGE_SED2)" >> "$(MAIN_STAGE)"
$(ENGINECFG_STAGE) : $(srcdir)mkenginecfg
@$(info) 'Making enginecfg: mostly counting processors'
@"$(srcdir)mkenginecfg" "$(srcdir)" "$(builddir)" "$(HISCORE_FILE)"
build-freedesktop : FORCE
@: # Refer to desktop/README for information about the following.
@"$(FD_MK_DESKTOP)" "$(FD_DESKTOP_STAGE)" $(NAME) "$(NAME_C)" \
"$(DESCRIPTION) -- version $(VERSION)"
build-macosx : FORCE
@: # Refer to desktop/README for information about the following.
@echo '#!/bin/sh' > "$(OSX_WRAPPER)"
......@@ -113,15 +113,18 @@ build-macosx : FORCE
"$(NAME_C) - $(DESCRIPTION)" $(VERSION) $(NAME)
@python "$(OSX_MK_ICON)" "$(OSX_ICON)" "$(srcdir)desktop/$(NAME)"
clean : FORCE
@rm $(ALL_STAGE) 2> /dev/null || true
@: # Remove the bytecode files.
@rm -- "$(srcdir)"*.pyc 2> /dev/null || true
@rm -r -- "$(srcdir)"__pycache__/ 2> /dev/null || true
distclean : clean
@rm $(builddir)Makefile
# configure.py will choose /usr/ucb/install on Solares.
INSTALL ?= install
......@@ -171,6 +174,7 @@ check-install-cfg : FORCE
@$(INSTALL_CFG) "$(srcdir)cursescfg" "$(CFG_DIR)/cursescfg" $(verbose)
@$(INSTALL_CFG) "$(ENGINECFG_STAGE)" "$(CFG_DIR)/enginecfg" $(verbose)
overwrite-cfg: FORCE
@echo "overwrite-cfg has been disabled" >/dev/stderr && false
@false
......@@ -179,6 +183,7 @@ overwrite-cfg: FORCE
@$(info) "Configuration has been overwritten"
@$(info) "All (if any) system-wide modifications are lost"
install-dirs : FORCE
@$(info) 'Installing directories'
@mkdir -p "$(CFG_DIR)" || true
......@@ -198,6 +203,7 @@ install-dirs : FORCE
$(INSTALL) -d "$(BUNDLE)/Contents/Resources"; \
fi
install : check-install-cfg install-dirs
@$(NORMAL_INSTALL)
@: # When the configuration has been installed, install the main
......@@ -241,45 +247,7 @@ install : check-install-cfg install-dirs
xdg-desktop-menu install --novendor --mode system \
"$(FD_DESKTOP_DEST)" || true; \
fi
@if "$(windows)"; then \
$(info) 'Installing shortcuts'; \
$(INSTALL) "$(CYG_ICO_SRC)" "$(CYG_ICO_DEST)"; \
mkshortcut -A -P -a '-lc $(NAME)' -n "$(NAME_C)" \
-i "$(CYG_ICO_DEST)" /bin/bash.exe || \
mkshortcut -P -a '-lc $(NAME)' -n "$(NAME_C)" \
-i "$(CYG_ICO_DEST)" /bin/bash.exe; \
\
mkshortcut -A -D -a '-lc $(NAME)' -n "$(NAME_C)" \
-i "$(CYG_ICO_DEST)" /bin/bash.exe || \
mkshortcut -D -a '-lc $(NAME)' -n "$(NAME_C)" \
-i "$(CYG_ICO_DEST)" /bin/bash.exe; \
\
mkshortcut -A -P -n "Uninstall $(NAME_C)" \
-a '-lc "make uninstall && (./rmssh || true) && cd .. \
&& rm -r ./$(NAME)*/" && /setup.exe' \
-w "`pwd`" /bin/bash.exe || \
mkshortcut -P -n "Uninstall $(NAME_C)" \
-a '-lc "make uninstall && (./rmssh || true) && cd .. \
&& rm -r ./$(NAME)*/" && /setup.exe' \
-w "`pwd`" /bin/bash.exe; \
fi
# http://superuser.com/questions/86078/where-do-start-menu-all-programs-shortcuts-reside
W_C := $(DESTDIR)/cygdrive/c
W_U := $(DESTDIR)`cygpath --unix '$(USERPROFILE)'`
# Ugh: use $(NAME_C)*.lnk to get the uninstall .lnk removed as well.
W_F := Anonymine*.lnk
W_M := /Start Menu/Programs/
# W_C is the C drive, W_U is the users real home directory,
# W_F is the filename and W_M is a part of the path to the start menu
# common for both NT 5 and 6.
CYG_STARTMENU_NT5X_ALL := $(W_C)/Documents and Settings/All Users$(W_M)$(W_F)
CYG_STARTMENU_NT5X_ME := $(W_U)$(W_M)$(W_F)
CYG_STARTMENU_NT6X_ALL := $(W_C)/ProgramData/Microsoft/Windows$(W_M)$(W_F)
CYG_STARTMENU_NT6X_ME := $(W_U)/AppData/Roaming/Microsoft/Windows$(W_M)$(W_F)
CYG_DESKTOP_NT5X_ALL := $(W_C)/Documents and Settings/All Users/Desktop$(W_F)
CYG_DESKTOP_NT6X_ALL := $(W_C)/Users/Public/Desktop/$(W_F)
CYG_DESKTOP_ME := $(W_U)/Desktop/$(W_F)
uninstall: FORCE
@$(PRE_UNINSTALL)
......@@ -301,15 +269,7 @@ uninstall: FORCE
@if "$(macosx)"; then \
rm -r "$(BUNDLE)" || true; \
fi
@if "$(windows)"; then \
rm "$(CYG_STARTMENU_NT5X_ALL)" || true; \
rm "$(CYG_STARTMENU_NT5X_ME)" || true; \
rm "$(CYG_STARTMENU_NT6X_ALL)" || true; \
rm "$(CYG_STARTMENU_NT6X_ME)" || true; \
rm "$(CYG_DESKTOP_NT5X_ALL)" || true; \
rm "$(CYG_DESKTOP_NT6X_ALL)" || true; \
rm "$(CYG_DESKTOP_ME)" || true; \
fi
print-destinations: FORCE
@echo "Main program: $(MAIN_DEST)"
......@@ -334,29 +294,21 @@ print-destinations: FORCE
@if "$(macosx)"; then \
echo "[Mac OS X] Bundle (App): $(BUNDLE) (directory)"; \
fi
@if "$(windows)"; then \
echo "[Windows] Shortcut: $(CYG_STARTMENU_NT5X_ALL)"; \
echo "[Windows] Shortcut: $(CYG_STARTMENU_NT5X_ME)"; \
echo "[Windows] Shortcut: $(CYG_STARTMENU_NT6X_ALL)"; \
echo "[Windows] Shortcut: $(CYG_STARTMENU_NT6X_ME)"; \
echo "[Windows] Shortcut: $(CYG_DESKTOP_NT5X_ALL)"; \
echo "[Windows] Shortcut: $(CYG_DESKTOP_NT6X_ALL)"; \
echo "[Windows] Shortcut: $(CYG_DESKTOP_ME)"; \
echo "[Windows] Icon: $(CYG_ICO_DEST)"; \
fi
test : check
@true
check: FORCE
@$(info) "Checking that it works on both snakes... May take a while!"
@$(srcdir)check.sh "$(srcdir)" "$(builddir)"
dist : FORCE
@$(info) "Building tarballs..."
@cd "$(builddir)" && make tarballs > /dev/null
@$(info) "Maybe building a zip for Windrugs users..."
@cd "$(builddir)" && make zip > /dev/null
release : dist check
@cp -t ~www-data/archive/"$(NAME)/" "$(PKG).tar.gz" \
......@@ -366,12 +318,11 @@ release : dist check
@cp -t ~www-data/archive/"$(NAME)/" "$(PKG).zip" \
|| echo You are not me.
PKG := $(NAME)-$(VERSION)
tarballs : FORCE
@$(srcdir)mkdist "$(srcdir)" "$(builddir)" "$(PKG)" tar
zip : FORCE
@$(srcdir)mkdist "$(srcdir)" "$(builddir)" "$(PKG)" zip
FORCE:
@echo off
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Where you want Cygwin to be installed:
set cygwin_dir=C:\Cygwin
:: Where you want the Cygwin installer to be placed, (including filename):
set cygwin_setup=%cygwin_dir%\setup.exe
:: Temporary, make sure this doesn't exist.
set dlroot=C:\Tmp-anonymine
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: URLs and valid destination file names.
set src64=https://cygwin.com/setup-x86_64.exe
set src32=https://cygwin.com/setup-x86.exe
set dl64=%dlroot%\setup-x86_64.exe
set dl32=%dlroot%\setup-x86.exe
:: 64/32
if exist %systemroot%\SysWOW64\ set src=%src64%
if exist %systemroot%\SysWOW64\ set dl_setup=%dl64%
if not exist %systemroot%\SysWOW64\ set src=%src32%
if not exist %systemroot%\SysWOW64\ set dl_setup=%dl32%
:: http://stackoverflow.com/questions/9681863/windows-batch-variables-wont-set
:: Can't have these in the conditional that checks whether Cygwin exists or not.
:: Procedures:
:: 1. Install Cygwin if needed.
:: 2. Install the dependencies of the game.
:: 3. Start a Cygwin environment.
:: 4. Install the game.
:: Information:
:: https://cygwin.com/cgi-bin2/package-grep.cgi
:: http://ss64.com/nt/syntax.html
:: http://ss64.com/nt/bitsadmin.html
:: BITS is so retarded that the source file needs o have the same name
:: as the destination file, and you also have to use an absolute path.
if exist %cygwin_dir% (
echo Cygwin appears to be pre-installed.
) else (
echo Downloading %src%
mkdir %dlroot%
bitsadmin /CREATE Anonymine_Cygwin_DL
bitsadmin /ADDFILE Anonymine_Cygwin_DL %src% %dl_setup%
bitsadmin /TRANSFER Anonymine_Cygwin_DL %src% %dl_setup%
echo Installing Cygwin
%dl_setup% --wait -q -R %cygwin_dir%
move %dl_setup% %cygwin_setup%
rmdir %dlroot%
)
echo Installing %python_pkg% and the game
%cygwin_setup% --wait -q -M -R %cygwin_dir% -P python -P make
:: bash -l to use the Cygwin $PATH rather than the MS %PATH%.
:: Then you'll need to go back to $OLDPWD.
%cygwin_dir%\bin\bash -lc 'echo "(Workaround): Do not remove!"'
%cygwin_dir%\bin\bash -lc ^
'cd $OLDPWD; ./configure -v && make && make install && ./cygwin-sshd rmssh'
@echo off
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Where you want Cygwin to be installed:
set cygwin_dir=%userprofile%\Cygwin
:: Where you want the Cygwin installer to be placed, (including filename):
set cygwin_setup=%cygwin_dir%\setup.exe
:: Temporary, make sure this doesn't exist.
set dlroot=%userprofile%\Tmp-anonymine
:: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: URLs and valid destination file names.
set src64=https://cygwin.com/setup-x86_64.exe
set src32=https://cygwin.com/setup-x86.exe
set dl64=%dlroot%\setup-x86_64.exe
set dl32=%dlroot%\setup-x86.exe
:: 64/32
if exist %systemroot%\SysWOW64\ set src=%src64%
if exist %systemroot%\SysWOW64\ set dl_setup=%dl64%
if not exist %systemroot%\SysWOW64\ set src=%src32%
if not exist %systemroot%\SysWOW64\ set dl_setup=%dl32%
:: http://stackoverflow.com/questions/9681863/windows-batch-variables-wont-set
:: Can't have these in the conditional that checks whether Cygwin exists or not.
:: Procedures:
:: 1. Install Cygwin if needed.
:: 2. Install the dependencies of the game.
:: 3. Start a Cygwin environment.
:: 4. Install the game.
:: Information:
:: https://cygwin.com/cgi-bin2/package-grep.cgi
:: http://ss64.com/nt/syntax.html
:: http://ss64.com/nt/bitsadmin.html
:: BITS is so retarded that the source file needs o have the same name
:: as the destination file, and you also have to use an absolute path.
if exist %cygwin_dir% (
echo Cygwin appears to be pre-installed.
) else (
echo Downloading %src%
mkdir %dlroot%
bitsadmin /CREATE Anonymine_Cygwin_DL
bitsadmin /ADDFILE Anonymine_Cygwin_DL %src% %dl_setup%
bitsadmin /TRANSFER Anonymine_Cygwin_DL %src% %dl_setup%
echo Installing Cygwin
%dl_setup% -B -q -R %cygwin_dir%
move %dl_setup% %cygwin_setup%
rmdir %dlroot%
)
echo Installing %python_pkg% and the game
%cygwin_setup% -B -q -M -R %cygwin_dir% -P python -P make
:: bash -l to use the Cygwin $PATH rather than the MS %PATH%.
:: Then you'll need to go back to $OLDPWD.
%cygwin_dir%\bin\bash -lc 'echo "(Workaround): Do not remove!"'
%cygwin_dir%\bin\bash -lc 'cd $OLDPWD; ./configure -v; make; make install'
......@@ -473,7 +473,6 @@ def detect_desktop(Makefile, flags):
Sets Makefile['freedesktop'] if needed.
Sets Makefile['macosx'] if needed.
Sets Makefile['windows'] if needed.
The value for these variables are either 'true' or 'false'.
......@@ -483,7 +482,6 @@ def detect_desktop(Makefile, flags):
mapping = {
'freedesktop': '/usr/share/applications',
'macosx': '/Applications',
'windows': '/cygdrive',
}
for desktop in mapping:
if desktop not in Makefile:
......@@ -551,7 +549,6 @@ def main():
'INSTALL',
'freedesktop',
'macosx',
'windows',
'sysconfdir',
'vargamesdir',
)
......
#!/bin/bash
# Automatically set up an Anonymine server on Windows.
# This requires Administrator privileges.
# ssh-host-config
# -u cyg_server # << username
# -N cygwin-sshd # << username, servicename
# Self-explanatory
error ()
{
while [ $# -gt 0 ]; do
echo "<<error>> $1" > /dev/stderr
shift
done
# Keep executing.
}
fatal ()
{
while [ $# -gt 0 ]; do
echo "<<fatal>> $1" > /dev/stderr
shift
done
echo 'Execution stopped due to fatal error.' > /dev/stderr
exit 1
}
# Yes/no
ask ()
{
while true ; do
read -p "<<< $1? (yes/no): " answer
if [ -n "`echo $answer | grep -E '^[Yy]([Ee][Ss])?$'`" ]; then
return 0
fi
if [ -n "`echo $answer | grep -E '^[Nn][Oo]?$'`" ]; then
return 1
fi
done
}
get_username ()
{
# NOTICE: All output MUST go to stderr,
# because this will be used as a function.
while true ; do
read -p 'Enter username for Anonymine account: ' username
if [ -n "$(echo "$username" | tr -d [:alnum:]._-)" ]; then
error "Invalid username: Allowed characters are:"
error " lowercase letter" " uppercase letters"
error " digits" " dot, hyphen and underscore"
continue
fi
if [ -n "$(echo "$username" | grep -E '^[0-9._-].*')" ]; then
error "Invalid username: Must begin with a letter"
continue
fi
if [ -z "$username" ]; then
error "You can't have an empty user name"
continue
fi
occupied=0
for existing in $@; do
[ $username = $existing ] && { occupied=1; break; }
done
if [ $occupied -ne 0 ]; then
error "You have already added this user"
continue
fi
break
done
echo $username
}
mk_uninstall_file ()
{
filename=$1
shift
all_users=$@
which_anonymine="$(which anonymine)"
cat > "$filename" << __EOF__
#!/bin/bash
ask ()
{
while true ; do
read -p "<<< \$1? (yes/no): " answer
if [ -n "\$(echo \$answer | grep -E '^[Yy]([Ee][Ss])?\$')" ]; then
return 0
fi
if [ -n "\$(echo \$answer | grep -E '^[Nn][Oo]?\$')" ]; then
return 1
fi
done
}
rm_users_passwd ()
{
echo "About to remove added users from /etc/passwd"
if ask "Allow"; then
cp /etc/passwd /etc/passwd.old.cygwin-sshd
grep -v ":${which_anonymine}"'\$' /etc/passwd.old.cygwin-sshd \
> /etc/passwd
fi
}
rm_sshd_conf ()
{
echo "About to remove all AllowUsers lines from /etc/sshd_config"
echo "Only allow this if you haven't modified it manually"
if ask "Allow"; then
cp /etc/sshd_config /etc/sshd_config.old.cygwin-sshd
grep -v '^AllowUsers ' /etc/sshd_config.old.cygwin-sshd \
> /etc/sshd_config
fi
}
rm_sshd ()
{
cygrunsrv --stop cygwin-sshd
cygrunsrv --remove cygwin-sshd
net user cygwin-sshd /delete
ask "Delete user cyg_server too" && net user cyg_server /delete
/setup.exe -R "\$(cygpath --windows /)" -x openssh
}
rm_users ()
{
__EOF__
for username in $all_users; do
echo " net user $username /delete" >> "$filename"
done
cat >> "$filename" << __EOF__
}
main ()
{
if ask "Remove Anonymine SSH users"; then
rm_users
rm_users_passwd
rm_sshd_conf
fi
ask "Remove the SSH daemon" && rm_sshd
}
main
__EOF__
chmod +x "$filename"
}
get_password ()
{
# NOTICE: All output MUST go to stderr,
# because this will be used as a function.
username=$1
while true ; do
read -p "Enter (weak) password for $1: " password
if [ -z "$password" ]; then
error "You can't have an empty password"
continue
fi
break
done
echo "$password"
}
add_user ()
{
username=$1
password="$2"
# Add the user to Windows.
# (Should be obvious due to the ass-backward syntax for commands.)
net user $username "$password" /add /active:yes \
/comment:"Account for Anonymine over SSH ($username)" \
|| fatal "Failed to add user $username"
# Add to /etc/passwd manually and replace the shell.
# (mkpasswd(1) can't handle non standard shells.)
line="$(mkpasswd -l -u $username | cut -f 1-6 -d :)"
echo "$line:$(which anonymine)" >> /etc/passwd
# Not created by default.
# NOTICE: I don't remember why I put these here. Why are they needed?
#mkdir /home/$username
#chmod 777 /home/$username
}
install ()
{
uninstall_file="$1"
# Install the SSH daemon
if ! ask 'Is the SSH daemon installed'; then
/setup.exe --wait -q -R `cygpath --windows /` -P openssh -P cygrunsrv \
|| fatal "setup.exe is not /setup.exe from within Cygwin"
ssh-host-config -c ntsec -u cyg_server -N cygwin-sshd -y \
|| fatal "ssh-host-config failed"
fi
# Add Anonymine as a shell.
echo `which anonymine` >> /etc/shells
# Add users.
all_users=""
while true ; do
username=$(get_username $all_users)
password=$(get_password $username)
all_users="$all_users $username"
add_user $username "$password"
ask "Add another user" || break
done
# Needs to be done before the script gets a chance to exit.
mk_uninstall_file "$uninstall_file" $all_users
# Allow login only to the specified user names.
if [ "$(grep -Ec '^ *AllowUsers .*' /etc/sshd_config)" -eq 0 ]; then
echo "AllowUsers $all_users" >> /etc/sshd_config
else
error 'The SSH server seems to be configured already.'
error "The AllowUsers key was found in /etc/sshd_config"
ask "Configure manually" || fatal "Can't configure the SSH daemon."
echo "This is a new shell"
echo "exit when /etc/sshd_config has been configured"
bash
ask "Continue" || exit 0
fi
# Launch SSH daemon
echo 'Launching the SSH daemon, this may take a while...'
net start cygwin-sshd || fatal "Can't start the server"
cat << __EOF__
You can now play Anonymine on mobile platforms with an SSH client.
Host: Your IP address (local address)
Port: 22
User: $username (All: $allusers)
Password: $password (+ other)
It might not work outside the wifi depending on how the network is configured.
__EOF__
}
main ()
{
uninstall_file="$1"
test -d /cygdrive || fatal "This is not Cygwin"
cat << __EOF__
Anonymine won't work on mobile devices, but there are workarounds. This host
is capable of running Anonymine and an SSH server, which will allow you to
play on this computer from a remote terminal (your phone for instance).
https://github.com/oskar-skog/anonymine/wiki/Anonymine-on-mobile-platforms
__EOF__
ask "Install Anonymine server" || exit 0
cat > /dev/stderr << __EOF__
You're about to install an SSH daemon and add a user that can only play
Anonymine.
You install this at your own risk! Do check that you can't log in (via ssh)
as any other user than the one you create to play Anonymine on mobile devices.
If you are installing something else at the same time, race conditions
may occur, and if they do, they will probably be quite nasty.
Things that will be done:
- Install 'openssh' and 'cygrunsrv' with /setup.exe
- Run 'ssh-host-config' (which will do various things)
- Modify '/etc/sshd_config'
- Modify '/etc/shells'
- Add a user
- Modify '/etc/passwd'
- Start the SSH daemon
NOTICE: This MUST be run as administrator.
NOTICE: There is no automated "uninstaller".
__EOF__
ask Continue && install "$uninstall_file"
}
if [ $# -ne 1 ]; then
echo "Usage: $0 uninstall-file" > /dev/stderr
echo "uninstall-file will be a script to uninstall SSH" > /dev/stderr
else
# TODO: Check if $1 exists?
echo "WARNING: UNTESTED"
ask "Go ahead" && main $1
fi