title: alpine linux sh script not runable
body: <p>I made a simple script to change the hostname and IP of an Alpine VM I have tried to install bash and run it, have also tried with sh I don't know what else to do or try. Can someone please help me I will leave the script and outputs.</p>
  <p><strong>script</strong></p>
  <pre><code>#!/bin/bash
   
  #hostname change
  read -p &quot;New hostname &quot; newhostname
  echo &quot;$newhostname&quot; &gt; /etc/hostname
  sed -i s/alpine-blank/$newhostname/g /etc/hosts
  hostname -F /etc/hostname
  hostname
   
  echo ________________________________________
   
  #Change IP to staic
  read -p &quot;New static IP &quot; nsip
  sed -i s/#//g /etc/network/interfaces
  sed -i s/ip/$nsip/g /etc/network/interfaces
  sed -i s/hm/$newhostname/g /etc/network/interfaces
  sed -i 's/iface eth0 inet dchp/#iface eth0 inet dchp/g' /etc/network/interfaces
  service networking restart
  ip a
   
  echo ________________________________________
   
  #New motd
  echo &quot;IP: $nsip
   
  Hostname: $newhostname
   
  Alpine Linux 3&quot; &gt; /etc/motd
   
  echo ________________________________________
   
  #updates
  apk update
  apk upgrade
   
  echo ________________________________________
   
  #Reboot Y/N
  while true; do
      read -p &quot;confirm reboot. [Y/N]: &quot; yn
      case $yn in
          [Yy]* ) reboot; break;;
          [Nn]* ) exit;;
      esac
  done
  </code></pre>
  <p><strong>script output ran with bash</strong></p>
  <pre><code>alpine-blank:~# ls
  setup.sh
  alpine-blank:~# bash
  alpine-blank:~# echo $0
  bash
  alpine-blank:~# ./setup.sh
  bash: ./setup.sh: /bin/bash^M: bad interpreter: No such file or directory
  alpine-blank:~#
  </code></pre>
  <p>script ran with sh and shebang defining /bin/sh</p>
  <pre><code>alpine-blank:~# ls
  setup.sh
  alpine-blank:~# sed -n 1p setup.sh
  #!/bin/sh
  alpine-blank:~# sh
  alpine-blank:~# echo $0
  sh
  alpine-blank:~# ./setup.sh
  sh: ./setup.sh: not found
  alpine-blank:~# sh ./setup.sh
  : not found line 2:
  ': bad variable nameme
  : No such file or directory
  : not found line 8: hostname
  : not found line 9:
  ________________________________________
  : not found line 11:
  ': bad variable name
  : No such file or directorys
  : No such file or directorys
  : No such file or directorys
  : No such file or directorys
  '
  BusyBox v1.34.1 (2022-04-04 10:19:27 UTC) multi-call binary.
   
  Usage: ip [OPTIONS] address|route|link|tunnel|neigh|rule [ARGS]
   
  OPTIONS := -f[amily] inet|inet6|link | -o[neline]
   
  ip addr add|del IFADDR dev IFACE | show|flush [dev IFACE] [to PREFIX]
  ip route list|flush|add|del|change|append|replace|test ROUTE
  ip link set IFACE [up|down] [arp on|off] [multicast on|off]
          [promisc on|off] [mtu NUM] [name NAME] [qlen NUM] [address MAC]
          [master IFACE | nomaster]
  ip tunnel add|change|del|show [NAME]
          [mode ipip|gre|sit] [remote ADDR] [local ADDR] [ttl TTL]
  ip neigh show|flush [to PREFIX] [dev DEV] [nud STATE]
  ip rule [list] | add|del SELECTOR ACTION
  : not found line 20:
  ________________________________________
  : not found line 22:
  : not found line 29:
  ________________________________________
  : not found line 31:
  ' is not an apk command. See 'apk --help'.
  ' is not an apk command. See 'apk --help'.
  : not found line 35:
  ________________________________________
  : not found line 37:
  ./setup.sh: line 41: syntax error: unexpected word (expecting &quot;in&quot;)
  alpine-blank:~#
  </code></pre>